Created
August 31, 2011 06:27
-
-
Save jfcalvo/1182935 to your computer and use it in GitHub Desktop.
Ruby block example using each_with_index and inject at the same time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1, 2, 3, 4].each_with_index.inject(0) do | memo, (number, i) | | |
puts "number: #{number}, i: #{i}." | |
puts "memo: #{memo}." | |
memo += number | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment