S
salai
Dear all,
Can you help me how can I implement my own "has_key" method for "hash class."
class Hash
def my_each_key(&block)
self.each { |key|
yield(key[0])
}
end
def my_each_value(&block)
self.each { |value|
yield(value[1])
}
end
def has_key()
#todo
end
end
h = {1 => 1.0, 2 => 2.0, 3 => 3.0 }
many thanks in advance,
salai.
Can you help me how can I implement my own "has_key" method for "hash class."
class Hash
def my_each_key(&block)
self.each { |key|
yield(key[0])
}
end
def my_each_value(&block)
self.each { |value|
yield(value[1])
}
end
def has_key()
#todo
end
end
h = {1 => 1.0, 2 => 2.0, 3 => 3.0 }
many thanks in advance,
salai.