In Swift, you can use the ==
operator to compare two strings for equality.
In this example,
str1
and str2
with different values.==
operator.==
operator returns true
if the strings are equal, and false
otherwise.// Comparison of Strings in Swift
let str1 = "Hello"
let str2 = "hello"
let result = str1 == str2
print("Strings are equal: \(result)")
Strings are equal: false
In this tutorial, we learned How to Compare Two Strings in Swift language with well detailed examples.