how can I add a new fct to the class Hash

S

sayoyo

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
 
D

dblack

Hi --

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! http://www.manning.com/books/black
 
M

Mark Van Holstyn

------=_Part_8754_26584143.1142007459278
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

class Hash
def new_meth
puts 'do stuff here...'
end
end

h =3D {}
h.new_meth
=3D>


--
Mark Van Holstyn
(e-mail address removed)
http://lotswholetime.com

------=_Part_8754_26584143.1142007459278--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top