class MyHash
def initialize
@keys = []
@values = []
end
def [] index
@keys.each_with_index do |v, i|
if index =~ v
return @values[i]
end
end
nil
end
def []=(key, value)
@keys << key
@values << value
end
end
somehash = MyHash.new
somehash[/someregex/i] = 2
puts somehash["somestring"].inspect # nil
puts somehash["somEregexlalalala"].inspect # somevalue