R
Robert Klemme
Bertram Scharpf said:Hi,
Am Freitag, 28. Jan 2005, 19:05:54 +0900 schrieb Robert Klemme:
There's nothing magic. The first constant's name that the
class is assigned to will be the classes name.
c=Class.new #=> #<Class:0x401e8874>
d=c #=> #<Class:0x401e8874>
e=d #=> #<Class:0x401e8874>
F=e #=> F
G=c #=> F
c.name #=> "F"
The rule and behavior is clear. The magic is that the class name
automatically is set from the identifier of the constant - normally an
object (and a class is an object) does not get to know when it is assigned
to a var/const and to which var/const it is assigned. So obviously for
const assignments there is special code that sets a class's name if the
assigned instance is a class.
Kind regards
robert