Skip to content

Instantly share code, notes, and snippets.

@rubydubee
Created June 27, 2013 15:29
Show Gist options
  • Save rubydubee/5877439 to your computer and use it in GitHub Desktop.
Save rubydubee/5877439 to your computer and use it in GitHub Desktop.
always add else if you are writing conditional statement inside inject.
[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