DevHeads.net

How does the class name magic with Class.new?

This seems like deep magic... Any idea how it works?

a = Class.new
=> #<Class:0x0000558d34f68b48>
It seems as if whenever you create a Constant it checks to see to see
if it is an unnamed class and then names it....

That seems..... too magic.

Comments

Re: How does the class name magic with Class.new?

By Matthew Kerwin at 06/10/2019 - 00:03

Yeah, no, that's pretty much exactly how it works.

On Mon, 10 Jun 2019 at 13:51, John Carter <john. ... at taitradio dot com> wrote:

Re: How does the class name magic with Class.new?

By John Carter at 06/10/2019 - 00:27

I tried digging about the ruby source code to spot where the magic
happen and/or find the documentation on const_set that says it's magic
and that magic can be relied on....

..no luck so far.

Any pointers as to exactly where that magic is implemented?

On Mon, Jun 10, 2019 at 4:03 PM Matthew Kerwin < ... at kerwin dot net.au> wrote: