3 ms·
Then why have 2 * 4 when you can write 2.multiply_by 4... What I love about ruby is its focus on making programming delightful rather than adhering to weird as
by fleitz 11y ago
Then why have 2 * 4 when you can write 2.multiply_by 4...
What I love about ruby is its focus on making programming delightful rather than adhering to weird ass rules like 'Ruby is object oriented, meaning you are calling methods on objects.' that people pretend are laws of physics when really you can break them anytime you want, unlike laws of physics.
Similar to the way you can write
def foo
"bar"
end
instead of
class Kernel
def foo
"bar"
end
end
- deleted 11y ago[deleted]
- mpweiher 11y agoSmalltalk messages/methods: a in: set. 2 * 4. Just sayin'
- chris_st 11y agoOf course, but then 2 * 4 + 5. In Smalltalk evaluates to 18.
- mpweiher 11y agoNo, that's 13. You probably meant 4 + 5 * 2. Also: Compilation Order: Smalltalk-78 had perpetuated the post-evaluation of receiver expressions so as to avoid delving into the stack to find the receiver. In the Smalltalk-80 language, however, we encoded the number of arguments in the send instruction. This enabled strictly left- to-right evaluation, and no one has since complained about surprising order of evaluation. We suspect that this change will yield further fruit in the future when someone tries to build a very simple compiler. http://sdmeta.gforge.inria.fr/FreeBooks/BitsOfHistory/BitsOfHistory.pdf http://sdmeta.gforge.inria.fr/FreeBooks/BitsOfHistory/BitsOf... p. 21
- chris_st 11y agoAh, thanks. I sit corrected :-)
- deleted 11y ago[deleted]
- wycats 11y agoThe difference here is that `` literally maps onto a method called `` in Ruby. I find this aspect of Ruby delightful and it's not something I willingly chip away at. Generally speaking, Ruby eschews syntax that invokes a protocol behind the scenes for a consistent 1:1 mapping between method syntax and the methods they invoke.