From: G Brandon Hoyt Date: 2010-09-23T22:00:16+09:00 Subject: Re: to make dot method dot method work? >> irb(main):012:0> Mycompute.new("Abc").values >> => "Abc" >> irb(main):013:0> >> irb(main):014:0* Mycompute.new("Abc").up >> => "ABC" >> irb(main):015:0> Mycompute.new("Abc").values.up >> NoMethodError: undefined method `up' for "Abc":String >> from (irb):15 >> from :0 Let's follow what happens, and maybe I will make more sense. Mycompute.new("Abc") ^^^^^^^^^^^^^^^^^^^^ creates a new object of class Mycompute with an instance variable of @str equalling the string "Abc" Mycompute.new("Abc").values ^^^^^^^^^^^^^ Creates another new object with instance variable equal to "Abc" and assigns value of @str to Class attribute @@result through the 'values' method. Mycompute.new("Abc").values returns a string Mycompute.new("Abc").values.up ^^^ Now we must think about the type of what is returned from our chained methods. 1. Mycompute.new creates a new object of type Mycompute, Mycompute objects have a method called 'values' 2. the method 'values' returns a string, and you attempt to call a method defined for class Mycompute on an object of type String. that don't work.