Advertisement
Guest User

Untitled

a guest
Oct 6th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. irb(main):032:0> ratings = Hash.new(0)
  2. => {}
  3. irb(main):033:0> books.values.each { |rate| ratings[rate]+= 1 }
  4. => [:super, :super, :nul, :archi_nul]
  5. irb(main):034:0> ratings
  6. => {:super=>2, :nul=>1, :archi_nul=>1}
  7. irb(main):035:0> ratings = {}
  8. => {}
  9. irb(main):036:0> books.values.each { |rate| ratings[rate]+= 1 }
  10. NoMethodError: undefined method `+' for nil:NilClass
  11. from (irb):36:in `block in irb_binding'
  12. from (irb):36:in `each'
  13. from (irb):36
  14. from /usr/bin/irb:12:in `<main>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement