Ruby/Development/ARGF
Материал из Wiki.crossplatform.ru
(Различия между версиями)
Версия 17:10, 26 мая 2010
ARGF.gets
#!/usr/bin/env ruby while line = ARGF.gets puts line end
ARGF ($
while line = ARGF.gets print line end
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"]