Re:Swift WTF
by mikeash on Sunday March 15, 2015 @12:28PM
(#9207036)
Swift's rules are pretty simple too: true is true, false is false, and nothing else is any sort of boolean. If you want to check whether an array is empty, do so explicitly. If you want to test an integer for zero, you have to do == 0. Even testing for nil requires an explicit != nil.
As for equality, I think it's just old bugs from an old prerelease compiler. These posts are ancient history, relatively speaking. I just tested on the latest public release and a == [1], [1] == a, and [1] == [1] all produced true, as one would expect. str === str won't compile, also as one would expect (String is a value type, and as such comparing object identity is nonsensical).
As for equality, I think it's just old bugs from an old prerelease compiler. These posts are ancient history, relatively speaking. I just tested on the latest public release and a == [1], [1] == a, and [1] == [1] all produced true, as one would expect. str === str won't compile, also as one would expect (String is a value type, and as such comparing object identity is nonsensical).