Ruby/Development/ARGF
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:55, 13 сентября 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"]