Wiki

Changes between Version 10 and Version 11 of RubyLanguage

Show
Ignore:
Timestamp:
05/05/10 12:21:34 (15 years ago)
Author:
Chuck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RubyLanguage

    v10 v11  
    7171 
    7272Notice that in Cobra, the first argument is the name of the program being called, while in Ruby it's the first parameter. 
    73 So, if we were to run the Cobra class above: 
    74  
    75 {{{ 
    76 cobra.exe a.cobra -run-args one two three 
     73If you were to run the Ruby script like this: 
     74 
     75{{{ 
     76ruby a.rb one two three 
     77}}} 
     78 
     79You would see this as the output: 
     80 
     81{{{ 
     82one 
     83two 
     84three 
     85}}} 
     86 
     87If we were to run the Cobra class above: 
     88 
     89{{{ 
     90cobra.exe a.cobra -- one two three 
    7791}}} 
    7892 
     
    8599}}} 
    86100 
    87 If you were to run the Ruby script like this: 
    88  
    89 {{{ 
    90 ruby a.rb one two three 
    91 }}} 
    92  
    93 You would see this as the output: 
    94  
    95 {{{ 
    96 one 
    97 two 
    98 three 
     101But you can use slicing to bypass the program name: 
     102{{{ 
     103#!python 
     104class A 
     105        def main is shared 
     106                for argument in CobraCore.commandLineArgs[1:] 
     107                        print argument 
    99108}}} 
    100109