Wiki

Changes between Version 9 and Version 10 of RubyLanguage

Show
Ignore:
Timestamp:
05/05/10 12:05:49 (15 years ago)
Author:
Gameday
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RubyLanguage

    v9 v10  
    5555== Code Examples == 
    5656 
     57=== Command line arguments === 
     58Ruby: 
     59{{{ 
     60#!ruby 
     61ARGV.each {|arg| puts arg} 
     62}}} 
     63Cobra: 
     64{{{ 
     65#!python 
     66class A 
     67        def main is shared 
     68                for argument in CobraCore.commandLineArgs 
     69                        print argument 
     70}}} 
     71 
     72Notice that in Cobra, the first argument is the name of the program being called, while in Ruby it's the first parameter. 
     73So, if we were to run the Cobra class above: 
     74 
     75{{{ 
     76cobra.exe a.cobra -run-args one two three 
     77}}} 
     78 
     79You would see the following output: 
     80{{{ 
     81a 
     82one 
     83two 
     84three 
     85}}} 
     86 
     87If you were to run the Ruby script like this: 
     88 
     89{{{ 
     90ruby a.rb one two three 
     91}}} 
     92 
     93You would see this as the output: 
     94 
     95{{{ 
     96one 
     97two 
     98three 
     99}}} 
     100 
    57101=== Class Declaration === 
    58102Ruby: