In article a6e48b6b.0306181426.62e8d934@posting.google.com,
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:
“<<” 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:
Phil
···
you CAN teach an old dog … itsme213@hotmail.com wrote: