Y
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
getsat
5121 days ago
It's probably better to think "everything that isn't
nil
or
false
is true".
link
xentronium
5121 days ago
0 is true too. I think that's actually brilliant.
[1,2,3].index(1) # => 0 [1,2,3].index(4) # => nil
link