DEV Community

Discussion on: Everything is an Object!

Collapse
 
tadman profile image
Scott Tadman

Methods as defined on a class, module or object directly are part of that object. They don't exist independently except when referenced with things like Method. I'm not sure this is inconsistent, it's just how it's structured. "Everything is an object, or a property of an object" is a more specific rule, perhaps?

Then there's the question of what method calls are. Are those objects too? They're messages passed between objects, an approach actually different from conventional function calls. Messages can be intercepted, redirected, rewritten and so on at run-time in a very arbitrary fashion, while function calls are often compiled into code as-is, immutably.

What is 1 + 2 in Ruby? The answer is not necessarily 3.

So maybe it should be "Everything in Ruby is an object, a property of an object, or a method call on an object."

Collapse
 
craigbrad profile image
Craig Bradley • Edited

Thanks for the response. The more you dig into the language, the more interesting it gets. Messages are an interesting subject and were out of scope of this post. I suppose it’s how you interpret “Everything is an object”. I debated including methods, but was hoping someone could clear it up.