Object id of nil false true in rails 4? -


What is the object id of false, false, empty, true and fiction in Ruby? How these objects are loaded in their priority.

Why does it give 4? I know that this is 4 but what is the logic behind the object id?

Why is the object id equal to zero? First of all, you have to know that false and true variables work equally in the same way as Zero does not. They are the singleton examples of FalseClass and TrueClass, respectively. When Ruby is booted above the interpreter, it starts the False class, Trueclass and the Nilclass.

The result is:

false.object_id = & gt; 0

true.object_id = & gt; 2

nil.biz_id = & gt; 4

What happened to 1 and 3? Well, for the first bit fixation values ​​(numbers) only reserved is simple and consistent.

You can follow the formula to get Fixnum's object ID: object_id = (n * 2) +1 [where n is tanum]

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -