Hacker News new | ask | show | jobs
by snorkel 5121 days ago
Empty string is true. Who here hasn't banged their head over that one?
2 comments

It's probably better to think "everything that isn't nil or false is true".
0 is true too. I think that's actually brilliant.

    [1,2,3].index(1)
    # => 0
    [1,2,3].index(4)
    # => nil