Example:
puts "No. of arguments:" << ARGV.length.to_s
puts "Loop elements"
for options in ARGV do
puts options
end
puts "Loop index"
for i in 0..ARGV.length-1
puts "#{i} #{ARGV[i]}"
end
$ ruby testcmd.rb one two three
No. of arguments:3
Loop elements
one
two
three
Loop index
0 one
1 two
2 three
No comments:
Post a Comment