Duping a class causes error

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
 
T

Trans

Nice. Thank you. That means I can give it a real Constant name, the
same as it was before, if I put it into an anonymous module. Right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top