From: hubert@... (Hubert Hung-Hsien Chang) Date: 2002-05-05T06:31:48+09:00 Subject: Re: Adding new method to Built-In class David Alan Black wrote in message news:... > > What you need to do is re-open the class String, and define a new > instance method: > > class String > def new_method > puts "give me a method!" > end > end > > "abcde".new_method # => give me a method! > Well..I have tried this before and it didn't give me anything unless of course you are runnig something else. > Doing it that way will cause every string object to respond to that > method. With what you originally did, you actually added a class > method to String: > > def String.new_method > puts "give me a method!" > end > > String.new_method # => give me a method! > I know. Hubert > .. so in that case, the object that responds to new_method is the > class String itself, rather than individual strings. > > > David