Answer the question
In order to leave comments, you need to log in
Is everything in Ruby an object?
There is a popular opinion that in ruby - all objects. I have doubts about some things.
Are the objects: method, block, keywords?
Answer the question
In order to leave comments, you need to log in
Everything. even nil is an object. I'm not sure about the method. How can a method be an object. And all other entities are indeed objects in the majority.
Methods are not objects, but we can get them as object #method
Keywords are not objects.
The block is not an object, to make it an object you need to use Proc, lambda
Generally speaking, any entity is ultimately a structure / instructions in memory, i.e. "object". The question is whether it is possible to access this entity from runtime/compiletime/designtime/etc. Most of these entities in Ruby can be accessed at runtime as standard language objects.
But for example, such access cannot be obtained to commands (compiled program code), although it can be done in another way - by reading the source codes of the executable program from itself, changing them and compiling using eval and transferring control to the new code.
By the way, note - execution contexts in functions / blocks are also language objects (Binding)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question