I think the approach that ruby took is one of individuality. Imaging that the "one preferred way" of adding elements to arrays was array << element.
array << element
You'd be surprised that something like array.push wasn't working, and even more surprised that array << element even existed.
array.push
Even though, in our hypothetical language, that's the only preferred way to push to arrays, it's still surprising.
If any of that made sense
It's fascinating to see how something like "principle of least surprise" can be interpreted and addressed so differently. The Ruby and Python solutions for this could not be more different.
It’s especially interesting because both languages (python 2.7 at least) are pretty similar from a high level technical point of view.
Both OOP style languages Both interpreted (usually) Both very high level Both dynamic Both are even heavily used in web development
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think the approach that ruby took is one of individuality. Imaging that the "one preferred way" of adding elements to arrays was
array << element
.You'd be surprised that something like
array.push
wasn't working, and even more surprised thatarray << element
even existed.Even though, in our hypothetical language, that's the only preferred way to push to arrays, it's still surprising.
If any of that made sense
It's fascinating to see how something like "principle of least surprise" can be interpreted and addressed so differently. The Ruby and Python solutions for this could not be more different.
It’s especially interesting because both languages (python 2.7 at least) are pretty similar from a high level technical point of view.
Both OOP style languages
Both interpreted (usually)
Both very high level
Both dynamic
Both are even heavily used in web development