Skip to content

Instantly share code, notes, and snippets.

@fuksito
Created August 31, 2015 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuksito/341c36ce3169d4ce1817 to your computer and use it in GitHub Desktop.
Save fuksito/341c36ce3169d4ce1817 to your computer and use it in GitHub Desktop.
ruby sum on array
> [nil].sum
=> 0
> [5,nil].sum
TypeError: nil can't be coerced into Fixnum
> [nil,5].sum
NoMethodError: undefined method `+' for nil:NilClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment