Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

"false", "true", and "nil" have ids?

I somehow ended up using something like "p @var.id" in one of my scripts, but @var was a variable that equalled nil, and it always showed 4. false shows 0, true shows 2, and nil shows 4. I used this in a script:
Code:
p false.id, true.id, nil.id
I was curious and wondered why. Does anyone know?
 
If you look in class Object, under object#id, it is the same thing as object#object_id...

So checking object#object_id, whcih returns the object identifier. No 2 objects will share the same id.

Code:
class Something
end

a = Something.new
b = Something.new
c = Something.new


p a.object_id, b.object_id, c.object_id

# Gives
538394172
538394152
538394142
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top