When the second and third operands of a ternary operator are the same, the operator will always return the same value regardless of the condition.
Either the operator itself is pointless, or a mistake was made in coding it.
Noncompliant Code Example
func canVote(person:Person) -> Bool {
return person.age > 18 ? true : true // Noncompliant; is this what was intended?
}
Compliant Solution
func canVote(person:Person) -> Bool {
return person.age > 18 ? true : false
}
Deprecated
This rule is deprecated; use {rule:swift:S3923} instead.