A key could be of any type in a hash table

A key in hash table could be anything. It could be an integer, a string, a boolean, an object, or even a function.

ht = HashTable.new

foo = ->() { puts "hello" }
ht['function'] = foo

puts ht['function'] # <Proc ... (lambda)>
ht['function'].call # hello
Backlinks: