Re:From Rails to Clojure, Then to Java, Then Back to Rails
by tinco on Wednesday March 21, 2018 @10:28PM
(#16645098)
It's not just 'anything' that objects are extended with in Ruby, they are extended with suitable methods pertaining to the domain at hand. 'seconds' is a conversion method of one type into another. You might as well ask why do objects have a 'toString' method. Because it is convenient.
[ Parent
| on HN ]
Re:From Rails to Clojure, Then to Java, Then Back to Rails
by pavlov on Thursday March 22, 2018 @05:26AM
(#16647097)
Why does one conversion method have the “to” prefix and the other doesn’t? I guess because the inconsistency looks somehow prettier.
But this is what drives me up the wall with the Ruby ecosystem: seems that whenever API designers had the choice between consistency and fun gimmick, they chose the latter. It makes some people feel happy, but often makes the next person who has to read and maintain the code miserable.
Re:From Rails to Clojure, Then to Java, Then Back to Rails
by jashmatthews on Thursday March 22, 2018 @07:47AM
(#16647736)
10.seconds is not part of the Ruby stdlib. It's Rails ActiveSupport. That's why it's different.