Skip to content

Instantly share code, notes, and snippets.

@sunchess
Created December 17, 2012 18:05
Show Gist options
  • Save sunchess/4320429 to your computer and use it in GitHub Desktop.
Save sunchess/4320429 to your computer and use it in GitHub Desktop.
@all_count = 0
list.each { |item| @all_count += item['quantity'] }
#short and correctly
@all_count = list.map(&:auantity).sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment