We check String equality in swift using "==".But how to use != (In objective c) equivalent in swift?I want to check str1!=str2.But compiler is suggesting me to delete '!' character.
The not equal to !=
operator is the same in Swift as in Objective C, because it is a standard C comparison operator
According to the Swift documentation for Basic Operators:
Swift supports all standard C comparison operators:
Equal to (a == b)
Not equal to (a != b)
The reason your example doesn't work, is because you must add whitespace:
str1!=str2
should be
str1 != str2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With