-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
This is not an appropriate use of ~=. The ~= operator in Swift is called "pattern match", but what it's specifically for is matching values in case statements. The ~= operator is how you can use nil and a..<b intervals in case statements, as well as Equatable values. The code
switch foo {
case 1..<10:
bar()
default:
baz()
}is equivalent to
switch foo {
case temp where 1..<10 ~= temp:
bar()
default:
baz()
(except without binding any identifiers).
Repurposing it here as a sort of pattern-match assignment is at the minimum very confusing. You should be using a different custom operator instead.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels