ruby code example(13)

ruby code example(13)
while gets
if /Ruby/
print
end
end

##等同代码

ARGF.each {|line| print line if line =~ /Ruby/ }
##ARGF
##An object providing access to virtual concatenation of files passed as command-line
##arguments or standard input if there are no command-line arguments. A synonym for
##$<.

##等同代码
print ARGF.grep(/Ruby/)

你可能感兴趣的:(ruby code example(13))