Override def method in CGI class, without altering the class

hello all,

I am a newbie to ruby.

how do I override a method from a particular class (in std class lib),
just
for one program, without modifying the class.

Thanks in advance for all your help.

-Jer A.

Just re-write it in your program where it’s needed.

class Foo
def bar
//method to override
end
end

Very simple.

  • Jer H.

highlyjhi wrote:

  • Jer H.

just for one program, without modifying the class.

Just to clarify, you can define or redefine methods of core classes:

Class String
def inspect
“This string’s value is “#{self}””
end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs