Title here
Summary here
Command-line arguments are a common way to parameterize execution of programs. For example, ruby hello.rb
uses hello.rb
as an argument to the ruby
program.
To experiment with command-line arguments, you can run the Ruby script directly:
In Ruby, command-line arguments are accessed through the ARGV
array. The program name is available separately through the $PROGRAM_NAME
global variable (also accessible as $0
).
Ruby doesn’t typically compile to binaries like some other languages, but it’s common to run Ruby scripts directly with the ruby
command.
Next, we’ll look at more advanced command-line processing with option parsing libraries in Ruby.