Ruby does have a method for this:
File.readlines('foo').each do |line|
puts(line)
end
More Related Contents:
- How to remove empty string in hash
- Strange, unexpected behavior (disappearing/changing values) when using Hash default value, e.g. Hash.new([])
- Why are exclamation marks used in Ruby methods?
- Difference between “or” and || in Ruby? [duplicate]
- Using do block vs braces {}
- How do I convert a String object into a Hash object?
- What is “main” in Ruby?
- How to modify PATH for Homebrew?
- Trying to learn / understand Ruby setter and getter methods
- Difference between a class and a module
- How to update Ruby Version 2.0.0 to the latest version in Mac OSX Yosemite?
- Why does string interpolation work in Ruby when there are no curly braces?
- How to implement an abstract class in Ruby
- Group hashes by keys and sum the values
- Is there a performance gain in using single quotes vs double quotes in ruby?
- Generating GUIDs in Ruby
- What is the easiest way to remove the first character from a string?
- what is “?” in ruby
- What do `?i` and `?-i` in regex mean?
- Ruby: how can I copy a variable without pointing to the same object?
- What does class_eval
- How to count duplicates in Ruby Arrays
- List comprehension in Ruby
- Ruby factorial function
- Read, edit, and write a text file line-wise using Ruby
- Ruby: filter array by regex?
- Insert digital signature into existing pdf file
- What will give me something like ruby readline with a default value?
- Functional code examples in ruby
- Read and write YAML files without destroying anchors and aliases?