There is a magic array named
It contains the command line arguments to the program.
If the user types:
ruby hello.rb Alice Bob
then ARGV contains:
ARGV is a historical name. It means "Argument Vector" and has been around since the early 1970s.
hello.rb to contain:
puts "Hello, " + ARGV
and run it a few times, e.g.
ruby hello.rb Alice
LAB: Hello, Everyone!
hello.rb to say hello to every one of its command line arguments.
ruby hello.rb Alice Bob Charlie Hello, Alice! Hello, Bob! Hello, Charlie!
Write a program named
add.rb that adds all of its command line arguments together.
ruby add.rb 1 2 3 6
Do you remember how to convert a string to an integer?