What\'s the point of ARGV in Ruby?
first, second, third = ARGV
puts \"The script is called: #{$0}\"
puts \"Your first variable is: #{first}\"
puts \"Your se
What's the point of
ARGV
in Ruby?
ARGV "contains the arguments passed to your script, one per element."
What's the point of this when to run the file you need to do:
ruby ex1.rb
and to put in the first, second and third variables you need to type inruby ex1.rb blah blah blah
.
That is the exact point, to be able to specify arguments when running the file like:
ruby ex1.rb -a -b 3
How does this benefit at all the person running the program?
Same benefit any other command-line program gets from being able to do so: the user can specify upfront what they want, and it's easier to script than an interactive CLI.
They can't do it anyway since I'd assume it be an executable.
Yes, they can. You just gave an example of exactly how the user would run your program that way. Whether it's executable or not doesn't change anything.