G
Greg Weeks
I'm sorry about the bandwidth, but I just read "How Classes and Objects
Interact" from Chapter 24 ("Classes and Objects") of the Pickaxe book,
and I *have* to comment that it is so clear that it hurts. I hate to
cut into book sales, but that section should be readily available --
diagrams and all -- on the web. Is it?
The grey box, "Metaclasses and Singleton Classes", was of special
interest. Matz is quoted as saying that the class <<Foo -- as in
"class <<Foo ... end" -- is "not a class of a class; it's a singleton
class of a class." Hmmm:
class Foo
class <<Foo
p (Foo.is_a? self) # true, and
p (self.is_a? Class) # true, but
p (Foo.class == self) # false
end
end
The ".class" call above returns a *named* class, rather than the
anonymous (or "virtual") class that, in the underlying implementation,
actually holds Foo (and only Foo). Whew!
In any case, I've seen nothing even approaching the clarity of the
Pickaxe text.
PS: In my recent exposure to Ruby, I've become so addicted to poetry
mode that I'd rather write
p (Foo.is_a? self)
than:
p Foo.is_a?(self)
Indeed, I originally omitted the parentheses entirely and was not
pleased to be warned to "parenthesize argument(s) for future version".
I'm definitely being corrupted.
PS: For anyone who thinks that this newbie (me) has been posting too
much recently: I'M GOING TO TRY TO STOP!
Interact" from Chapter 24 ("Classes and Objects") of the Pickaxe book,
and I *have* to comment that it is so clear that it hurts. I hate to
cut into book sales, but that section should be readily available --
diagrams and all -- on the web. Is it?
The grey box, "Metaclasses and Singleton Classes", was of special
interest. Matz is quoted as saying that the class <<Foo -- as in
"class <<Foo ... end" -- is "not a class of a class; it's a singleton
class of a class." Hmmm:
class Foo
class <<Foo
p (Foo.is_a? self) # true, and
p (self.is_a? Class) # true, but
p (Foo.class == self) # false
end
end
The ".class" call above returns a *named* class, rather than the
anonymous (or "virtual") class that, in the underlying implementation,
actually holds Foo (and only Foo). Whew!
In any case, I've seen nothing even approaching the clarity of the
Pickaxe text.
PS: In my recent exposure to Ruby, I've become so addicted to poetry
mode that I'd rather write
p (Foo.is_a? self)
than:
p Foo.is_a?(self)
Indeed, I originally omitted the parentheses entirely and was not
pleased to be warned to "parenthesize argument(s) for future version".
I'm definitely being corrupted.
PS: For anyone who thinks that this newbie (me) has been posting too
much recently: I'M GOING TO TRY TO STOP!