From: Hal Fulton Date: 2004-07-04T17:40:16+09:00 Subject: Re: Beginner question Mikael Larsson wrote: > Tho book is really good, but the writer don't explain this construction (from > page 81) (or I haven't found the explanation): > > class String > def rot13 > self.tr!("A-Ma-mN-Zn-z", "N-Zn-zA-Ma-m") > end > end [snip] > For me looks like we are doing some implicit inherence here, like this: > class String < String > def rot13 > self.tr!("A-Ma-mN-Zn-z", "N-Zn-zA-Ma-m") > end > end > > Dose any one have a good explanation? Hi, Mikael... I think you're failing to understand that Ruby's classes are "open" -- i.e., all we're doing here is adding a new method to the String class. All instances of String have access to that method once you add it. (Even the ones that existed before the method was added.) Does that help any? Hal