On Fri, Jun 20, 2003 at 10:10:49AM +0900, Phil Tomson wrote: > In article <a6e48b6b.0306181426.62e8d934 / posting.google.com>, > you CAN teach an old dog ... <itsme213 / hotmail.com> wrote: > >I have seen this idiom quite a few times, and have not figured out > >what it does (looking at the pickaxe book). Could someone help > >enlighten me? > > > >[My guess is that it creates a customized meta-class that X is an > >instance of; am I guessing right?] > > I think that's a pretty close guess... > > Here's a section from the Rubygarden Wiki: > http://www.rubygarden.org/ruby?FunnySymbolsInCode > > "<<" also creates a new class based on a particular object. > These object-specific classes are called 'singleton classes'. > In the example below, only the Car object referred to by > "camaro" will have the method "has_flames?". > > camaro = Car.new > class << camaro > def has_flames? > true > end > end > > > See also TheScaryDoor on the wiki: > http://www.rubygarden.org/ruby?TheScaryDoor and: http://www.rubygarden.org/ruby?SingletonTutorial Regards, Brian.