Advertisement
Guest User

Untitled

a guest
Oct 6th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.90 KB | None | 0 0
  1. irb(main):014:0> books.values.each { |rate| ratings[rate] += 1 }
  2. NoMethodError: undefined method `+' for nil:NilClass
  3.        from (irb):14:in `block in irb_binding'
  4.        from (irb):14:in `each'
  5.         from (irb):14
  6.         from /usr/bin/irb:12:in `<main>'
  7.  
  8. irb(main):015:0> books.values.each { |rate| ratings[rate] =+ 1 }
  9. => [:super, :super, :nul, :archi_nul]
  10.  
  11. irb(main):016:0> ratings
  12. => {:super=>1, :nul=>1, :archi_nul=>1}
  13.  
  14. irb(main):017:0> books.values.each { |rate| ratings[rate]+= 1 }
  15. => [:super, :super, :nul, :archi_nul]
  16.  
  17. irb(main):018:0> ratings
  18. => {:super=>3, :nul=>2, :archi_nul=>2}
  19.  
  20. irb(main):019:0> ratings = {}
  21. => {}
  22.  
  23. irb(main):031:0> books.values.each { |rate| ratings[rate]+= 1 }
  24. NoMethodError: undefined method `+' for nil:NilClass
  25.        from (irb):31:in `block in irb_binding'
  26.         from (irb):31:in `each'
  27.        from (irb):31
  28.        from /usr/bin/irb:12:in `<main>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement