> On 8 Apr 2016, at 11:32, Brent Royal-Gordon <[email protected]> wrote: > >> Can someone fill me in as to how this differs from (0…4).contains(x)? >> >> Personally I don’t like the choice for the operator, and think it’s not very >> clear, if we can do the same thing with a method then I’d prefer removing >> the operator to be honest. > > ~= is the way you customize how a type behaves when it's a pattern in a > switch statement. So ~= (_: Range<T>, _: T) is responsible for making `case > 1..<10` work properly. Removing it would be…unwise.
But why not just (1..<10).contains(x) behind the scenes instead? This could be redefined as a protocol or whatever. It’s just kind of strange as an operator, and as the OP said not especially well known. _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
