Skip to content

Instantly share code, notes, and snippets.

@headius
Created January 8, 2021 20:24
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 headius/e27f84f945ae670f82184f239d424e9e to your computer and use it in GitHub Desktop.
Save headius/e27f84f945ae670f82184f239d424e9e to your computer and use it in GitHub Desktop.
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