Post

Replies

Boosts

Views

Activity

Comment on Why does Array's contains(_:) method cause an error when comparing an optional value with a non-optional value in Swift?
This is the correct answer. contains can be turned into a (String?) -> Bool either by making the argument optional, which is what you did, or by making the array optional. Like, for example: let contains = ["hello" as _?, "world"].contains // (String?) -> Bool contains("hello")
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’25