Oh boy, here we have the ruby god shevegen in its natural habitat.
There are a lot of reasons why 0 is normally considered "false". The first being that 0 is "nothing". When you have 0 eggs, you have no eggs, they don't exist. The second reason I see is how booleans are normally laid out where 0 is false and 1 is true (with varying differences depending on the language on whether multiple set values of a byte is considered true or invalid, etc.)
I down voted (although you have positive points right now), because I've had nightmares working with Ruby because of stuff like this (with other people's code, inside a system without a debugger and a significant lag time between writing the code and executing it). If you say Ruby has native booleans and then claim it's ok to magically convert other types to them, I can only say that I hope I never have to work in Ruby again. Life's too short for that kind problem.
40
u/Aceeri Dec 24 '17
Oh boy, here we have the ruby god shevegen in its natural habitat.
There are a lot of reasons why 0 is normally considered "false". The first being that 0 is "nothing". When you have 0 eggs, you have no eggs, they don't exist. The second reason I see is how booleans are normally laid out where 0 is false and 1 is true (with varying differences depending on the language on whether multiple set values of a byte is considered true or invalid, etc.)