Skip to content

Instantly share code, notes, and snippets.

@jdunck
Created February 15, 2013 20:19
Show Gist options
  • Select an option

  • Save jdunck/4963232 to your computer and use it in GitHub Desktop.

Select an option

Save jdunck/4963232 to your computer and use it in GitHub Desktop.
ruby wat #2
hotsoup:causes jdunck$ irb
irb(main):001:0> def x()
irb(main):002:1> return 1
irb(main):003:1> end
=> nil
irb(main):004:0> h = {}
=> {}
irb(main):005:0> h[:a] = x
=> 1
irb(main):006:0> h
=> {:a=>1}
irb(main):007:0> h[:a] = method(:x)
=> #<Method: Object#x>
irb(main):008:0> h[:a]
=> #<Method: Object#x>
irb(main):009:0> h[:a].call
=> 1
irb(main):010:0> h[:a]
irb(main):011:0> z = h[:a]
=> #<Method: Object#x>
irb(main):012:0> z
=> #<Method: Object#x>
irb(main):013:0> x
=> 1
irb(main):014:0> z
=> #<Method: Object#x>
irb(main):015:0> z.call
=> 1
@cgriego
Copy link
Copy Markdown

cgriego commented Feb 15, 2013

The lack of output from line #18 is the only thing I don't follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment