Pattern or range to the left, value to the right:
if case .enumThing(let x, _) = value { ... } if 100..<200 ~= value { ... }
The pattern matching operator is pronounced “twiddle-eek” not “bacon rocket”. Not only more fun to say but tells you the order in which to type the symbols. If you insist you’d rather “eeky-twid” instead of proper twiddle-eeking, you can always wrap your own:
infix operator =~ { associativity none precedence 130 } public func =~<T : Equatable>(a: T, b: T) -> Bool { return b ~= a } public func =~<I : ForwardIndexType where I : Comparable>(value: I, pattern: Range<I>) -> Bool { return pattern ~= value } public func =~<I : IntervalType>(value: I.Bound, pattern: I) -> Bool { return pattern ~= value } public func =~<T>(lhs: T?, rhs: _OptionalNilComparisonType) -> Bool {return rhs ~= lhs }
One Comment
I’m going to say twiddle-eek in a meeting as soon as possible.