Created
June 27, 2013 15:29
-
-
Save rubydubee/5877439 to your computer and use it in GitHub Desktop.
always add else if you are writing conditional statement inside inject.
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
[35] pry(main)> total = words.inject(0){ |result, word| word.size > 3 ? word.size + result : result} | |
=> 14 | |
[36] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment