“you CAN teach an old dog …” itsme213@hotmail.com wrote in message news: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?]
That sounds a bit comp.sci
It’s usually a prelude to one or more class method definitions.
class Roo
class << Roo # or class << self
def class_meth1
end
def class_meth2
p 'class_meth2'
end
end
def Roo.class_meth3 # The usual(?) way
p ‘class_meth3’
end
def inst_meth1
p ‘inst_meth1’
end
end
Roo.class_meth2
Roo.class_meth3
r1 = Roo.new
r1.inst_meth1
r2 = Roo.new
r2.inst_meth1
#-> “class_meth2”
#-> “class_meth3”
#-> “inst_meth1”
#-> “inst_meth1”
daz