Skip to content

Instantly share code, notes, and snippets.

@brixen
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brixen/83f62c9bd6eed66f7864 to your computer and use it in GitHub Desktop.
Save brixen/83f62c9bd6eed66f7864 to your computer and use it in GitHub Desktop.
$ ruby -v kw.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
=> let's try with m(o)
#<Object:0x007f88219791d0>
=> and with m(**o)
--- to_hash ---
{:a=>1}
70111327930320
#<Object:0x007f88219791d0>
=> how about mk(o)
--- to_hash ---
{:a=>1}
70111327929960
1
=> and mk(**o)
--- to_hash ---
{:a=>1}
70111327929620
--- to_hash ---
{:a=>1}
70111327929400
1
def m(a)
a
end
def mk(a:)
a
end
o = Object.new
def o.to_hash
puts "--- to_hash ---"
h = { a: 1 }
p h, h.object_id
h
end
puts "=> let's try with m(o)"
p m(o)
puts "=> and with m(**o)"
p m(**o)
puts "=> how about mk(o)"
p mk(o)
puts "=> and mk(**o)"
p mk(**o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment