Skip to content

Instantly share code, notes, and snippets.

@enebo
Created November 8, 2022 17:22
Show Gist options
  • Save enebo/5d75a524499c24a647c0643a33dbe431 to your computer and use it in GitHub Desktop.
Save enebo/5d75a524499c24a647c0643a33dbe431 to your computer and use it in GitHub Desktop.
require 'java'
class WrappedHash < Hash
def initialize(value)
@value = value
end
def [](key)
@value[key]
end
end
class Java::java::util::HashMap
def to_hash
WrappedHash.new(self)
end
end
h = java.util.HashMap.new
h["one"] = 2
def foo(one:)
p one
end
foo(**h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment