Skip to content

Instantly share code, notes, and snippets.

@ajokela
Created June 22, 2012 18:34
Show Gist options
  • Save ajokela/2974420 to your computer and use it in GitHub Desktop.
Save ajokela/2974420 to your computer and use it in GitHub Desktop.
Reading a file in one line - ruby
# If you need binary mode, you'll need to do it the hard way:
s = File.open(filename, 'rb') { |f| f.read }
# If not, shorter and sweeter is:
s = IO.read(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment