How constant lookup works in Ruby

#code #summary #ruby #how #constant #works #class #modules

This is a code summary for https://cirw.in/blog/constant-lookup

Code samples run on Ruby 3.1.2

Find all the code I used to generate images here.

You should also read the full article I summarised here as I did not include all examples from the article, but only the most important ones.

Further reading:

I also found a gist that explains some of how constant lookup works in Ruby with code: Constant Lookup in Ruby

And also, this discussion in the Ruby lang issue tracker is important if you want to understand how all works deep down: https://bugs.ruby-lang.org/issues/18622

Reply

or to participate.