Using pattern matching for if let
/ guard let
is actually in the commonly rejected proposals list.
Use pattern-matching in
if let
instead of optional-unwrapping: We actually tried this and got a lot of negative feedback, for several reasons: (1) Most developers don't think about things in "pattern matching" terms, they think about "destructuring". (2) The vastly most common use case forif let
is actually for optional matching, and this change made the common case more awkward. (3) This change increases the learning curve of Swift, changing pattern matching from being a concept that can be learned late to something that must be confronted early. (4) The current design ofif case
unifies "pattern matching" around thecase
keyword. (5) If a developer unfamiliar withif case
runs into one in some code, they can successfully search for it in a search engine or Stack Overflow.