From: Brian Candler Date: 2010-09-24T22:22:38+09:00 Subject: Re: to make dot method dot method work? Pen Ttt wrote: > there is another way to solve it(an expert in stackover help me) > class Mycompute > def initialize(str) > @str=str > end > def values > @@result=@str > def @@result.up > self.upcase > end > @@result > end > def up > @@result.upcase > end > end Do you understand what you've done? At runtime you've added a custom method called 'up' to the String object you've returned. The String object is now a String with an extra method. It's a cool feature of Ruby, but not one you would want to use widely as a beginner. And why are you still assigning to @@result? Perhaps it would be better if you showed some real code, what you're actually trying to do. This 'Mycompute' example is not particularly useful, because right now it's just a wrapper for a String. -- Posted via http://www.ruby-forum.com/.