Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Empty string is true. Who here hasn't banged their head over that one?


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: