Skip to content

Instantly share code, notes, and snippets.

@ianbishop
Created May 10, 2012 22:18
Show Gist options
  • Select an option

  • Save ianbishop/2656257 to your computer and use it in GitHub Desktop.

Select an option

Save ianbishop/2656257 to your computer and use it in GitHub Desktop.
Symbol#to_proc .inject
a = [1,2,3,4,5]
# Sum
a.inject(&:+)
# => 15
# Product
a.inject(&:*)
# => 120
b = [true,true,false]
# Logical And
b.inject(&:&)
# => false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment