Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created November 20, 2018 03:54
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 mistyrinth/da922f3626d99743bfc0450454e6fc5c to your computer and use it in GitHub Desktop.
Save mistyrinth/da922f3626d99743bfc0450454e6fc5c to your computer and use it in GitHub Desktop.
hash = Hash.new{|hash, key|
if key.respond_to?(:*)
hash[key] = key * 2
else
:not_found
end
}
print(hash[2], "\n")
print(hash["hello"], "\n")
print(hash[Time.now], "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment