|
|
|
|
|
by jacques_chester
4035 days ago
|
|
> Is this a variable reference? Is it a method call? I dunno! Neither. It's a message sent to an object. The object decides how to respond to that message. Caring about the implementation of the message receiver breaks information hiding. If you have to distinguish between .message and .message(), you already know more than you need to know to interact with that object. Every language is confusing until you understand the mental model (even if you disagree with the utility of that model). If you come to Ruby thinking in Java/C++/C terms, you'll be unhappy, because the mental model is very different. For Ruby, the book to read is The Well-Grounded Rubyist, which makes the language quite obvious. |
|
Variables and methods are treated differently. I can't pass arguments to a variable, I can't even write foo(), but if it were a method I could. I can't treat variables like any other object because they have different rules applied.