Four Common (and Broken) Ruby Operations
All of these lines, in ruby, should fail. All of them instead return nil
:
@nonexistant_var
{}[:nonexistant_key]
[].first
{}.shift
All of these were encountered by myself in the course of yesterday’s programming. None of them in a good way. And the last two were in published libraries, not even code under development.
All of these, of course, raise errors in python. I refer you to lines 10 and 11 of the zen of python:
Errors should never pass silently.
Unless explicitly silenced
(an Option
or Maybe
type would be acceptable also, but that’s pretty uncommon to find in a dynamic language)
Also inviting my fury: every single language, tool or function, ever, that makes you check the return code of a system (shell) command to see whether it was nonzero.