A
A
alexnotonfire2017-03-15 18:13:58
ruby
alexnotonfire, 2017-03-15 18:13:58

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

3 answer(s)
E
Evgeny Svirsky, 2017-03-15
@e_svirsky

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.

A
Andrey Demidenko, 2017-03-15
@Dem1

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

V
vsuhachev, 2017-03-16
@vsuhachev

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 question

Ask a Question

731 491 924 answers to any question