Skip to content

Instantly share code, notes, and snippets.

@paulsturgess
Created February 27, 2013 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulsturgess/5050928 to your computer and use it in GitHub Desktop.
Save paulsturgess/5050928 to your computer and use it in GitHub Desktop.
Ruby read from file
$ cat somefile.txt | ruby version*.rb

Version 1:

input = $stdin.read
input.each_line do |line|
  ...
end

Version 2:

ARGF.each do |line|
  ...
end

Version 3:

while line = gets
  ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment