Last active
August 29, 2015 14:02
-
-
Save brixen/83f62c9bd6eed66f7864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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