Skip to content

Instantly share code, notes, and snippets.

@kyanny
Created June 2, 2012 16:50
Show Gist options
  • Save kyanny/2859130 to your computer and use it in GitHub Desktop.
Save kyanny/2859130 to your computer and use it in GitHub Desktop.
irb(main):003:0> require 'pp'
=> true
irb(main):004:0> [1,2,3].inject([]){ |r,i| pp r; r << i }
[]
[1]
[1, 2]
=> [1, 2, 3]
irb(main):005:0> [1,2,3].inject({}){ |r,i| pp r; r[i] = i }
{}
1
NoMethodError: undefined method `[]=' for 1:Fixnum
from (irb):5:in `block in irb_binding'
from (irb):5:in `each'
from (irb):5:in `inject'
from (irb):5
from /Users/kyanny/.rbenv/versions/1.9.3-p194/bin/irb:12:in `<main>'
irb(main):006:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment