Re:Flappy Bird in Swift
by josephlord on Wednesday June 04, 2014 @08:01AM
(#7845050)
Just tried it.
In Swift:
3 == true // Give an error (operator overload doesn't cover this)
true == 3 // Returns false
nil == false // Returns false
You can't use nil or integers directly in an if statement without a function to return a logic value.Yes, such languages exist, and even in C++ if (x == true) is different from if (x), given that x is any number kind other than boolean, but my comment was only for the case when the two would be equivalent.
However in the strongly typed swift I don't think it will be a problem as I suspect (but haven't read/tested enough yet to confirm) that only false and nil will be falsy and that comparison with true will throw errors if var isn't of bool type.