From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2003-06-20T10:10:49+09:00 Subject: Re: class X; class << X : what is this idiom ? In article , you CAN teach an old dog ... 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 Phil