January 2024
Intermediate to advanced
718 pages
20h 15m
English
Finally, there’s one small detail we have to cover to complete the metaprogramming environment. Many times in this book we’ve claimed that everything in Ruby is an object. But we’ve used one thing time and time again that appears to contradict this—the top-level Ruby execution environment:
| | puts "Hello, World" |
Not an object in sight. We may as well be writing some variant of Fortran or Basic. But dig deeper, and you’ll come across objects and classes lurking in even the simplest code.
We know that the literal "Hello, World" generates a Ruby String, so that’s one object. We also know that the bare method call to puts is effectively the same as self.puts. But what is self?
| | self # => main |
| | self.class # => ... |
Read now
Unlock full access