Skip to content

Instantly share code, notes, and snippets.

@jorrizza
Created June 21, 2016 15:07
Show Gist options
  • Save jorrizza/18a4dad2328c02e30471c67ae2864230 to your computer and use it in GitHub Desktop.
Save jorrizza/18a4dad2328c02e30471c67ae2864230 to your computer and use it in GitHub Desktop.
I kind of hate Ruby for this
irb(main):001:0> wat = Hash.new {|h, k| h[k] = "Wat #{k}?"}
=> {}
irb(main):002:0> wat.keys
=> []
irb(main):003:0> wat.class
=> Hash
irb(main):004:0> puts 'wat?' if wat['foo']
wat?
=> nil
irb(main):005:0> wat.keys
=> ["foo"]
irb(main):006:0> wat
=> {"foo"=>"Wat foo?"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment