Hacker News new | past | comments | ask | show | jobs | submit login

Only false and nil are falsey, and the language shines for it. There is nothing weird about zero being a truthy value.



Yes, this is one of ruby's best features.


In what other languages does 0 evaluate to true?


Lua, Elixir, Common Lisp, Scheme, Racket, Clojure.

Most statically-typed languages don't let you evaluate 0 as a boolean.

IMO, 0 is a value, and values should be truthy. 0 being falsy is only a wart from C.


Thanks for that, I had no idea. Do you know if zero is truthy in erlang? It makes sense for elixir (based on ruby) but I'm wondering if erlang is that way too.


>Do you know if zero is truthy in erlang?

I don't know off the top of my head, but I would assume that yes, zero is truthy in Erlang as well, since Elixir is fully compatible with it.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: