5 ms·
It's always a method. Ruby doesn't expose instance variables unless you define accessor methods for them.
by jenrzzz 4y ago
It's always a method. Ruby doesn't expose instance variables unless you define accessor methods for them.
- fny 4y agoI'm going to emphasize this as well. Everything is an object, and everything called on an object is a method. Full stop. Unlike with other languages, there is no ambiguity here. In python, you don't know when you dir() an object whether your dealing with a property or method. In Ruby, you are guaranteed it's always a method. A perk is that you don't need parens.
- ek750 4y agoExactly. Once you get some basics of Ruby, there is no ambiguity, and I find it quite elegant. And I think I’m in the minority here, but I prefer the cleanliness of optional punctuation. That feature also allows for fluent DSLs (which seem to be falling out of favor for various reasons), but is one of the reasons I still love Ruby. To look at the other side, I hate having to constantly add semicolons and parens in other languages. Makes my poor fingers hurt even more than they usually do.
- deleted 4y ago[deleted]