Created
January 8, 2021 20:24
-
-
Save headius/e27f84f945ae670f82184f239d424e9e 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
irb(main):001:0> map = java.util.concurrent.ConcurrentHashMap.new | |
=> #<Java::JavaUtilConcurrent::ConcurrentHashMap: {}> | |
irb(main):002:0> hash = Hash.new {|hash, key| p :here; hash[key]=1} | |
=> {} | |
irb(main):003:0> map.put("foo", hash) | |
=> nil | |
irb(main):004:0> map.toString | |
=> "{foo={}}" | |
irb(main):005:0> hash2 = map.get("foo") | |
=> {} | |
irb(main):006:0> hash2.equal?(hash) | |
=> true | |
irb(main):007:0> hash2["bar"] | |
:here | |
=> 1 | |
irb(main):008:0> hash2 | |
=> {"bar"=>1} | |
irb(main):009:0> hash | |
=> {"bar"=>1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment