How can I add a new fct to the class Hash

Hi,

We use a lot of “hash” in our program and we want to
add a new function to the class, does someone know how
to do this???

Thanks you very much

sayoyo

Hi –

On Sat, 11 Mar 2006, [email protected] wrote:

Hi,

We use a lot of “hash” in our program and we want to
add a new function to the class, does someone know how
to do this???

class Hash
def new_method
#…
end
end

Keep in mind, though, that it’s risky to change core classes unless
you’re certain that the code you’re writing won’t be mingled with
other code.

David


David A. Black ([email protected])
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

“Ruby for Rails” chapters now available
from Manning Early Access Program! Ruby for Rails

class Hash
def new_meth
puts ‘do stuff here…’
end
end

h = {}
h.new_meth
=>