Mega Code Archive

 
Categories / Ruby / Development
 

ARGV and ARGF

ARGV << "myFile.txt" print while gets # ARGV (or $*) is an array, and each of its elements is a filename submitted on the command line.  # You can apply any method to ARGV that you might apply to any other array.  p ARGV # => ["sonnet_119.txt"] # or: ARGV#[0] # => ["sonnet_119.txt"]