I was trying to evaulate
let myTuple = ("blue", false) let otherTuple = ("blue", true) if myTuple < otherTuple { print("yes it evaluates") }
Ans I got
/tmp/S9jAk7P7KW/main.swift:5:12: error: binary operator '<' cannot be applied to two '(String, Bool)' operands if myTuple < otherTuple {
My question is why there is no compile time issue in first place where the declaration is
let myTuple = ("blue", false)
~~~~~~
something like above
true and false are not 1 and 0 as in other languages.
But of course, this works
let myTuple = ("blue", 0)
let otherTuple = ("blue", 1)
if myTuple < otherTuple { print("yes it evaluates") }
and this as well:
let myTuple2 = ("blue", false)
let otherTuple2 = ("blue", true)
if myTuple2 == otherTuple2 {
print("yes it evaluates")
} else {
print("Not equal")
}
You may be interested in reading this discussion in Swift forum: https://forums.swift.org/t/why-bool-doesnt-conform-to-comparable/10698/6