Skip to content

Instantly share code, notes, and snippets.

@shinokada
Created April 29, 2014 02:25
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 shinokada/11389349 to your computer and use it in GitHub Desktop.
Save shinokada/11389349 to your computer and use it in GitHub Desktop.
# read text from file, map to integer and sum all
File.new(file_name, 'r').each_line.map(&:strip).map(&:to_i).inject(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment