Format
Plain text
Post date
2017-01-24 18:11
Publication Period
Unlimited
  1. import Foundation
  2. precedencegroup Group {
  3. associativity: left
  4. lowerThan: RangeFormationPrecedence
  5. }
  6. infix operator ⊂ : Group
  7. func ⊂<T: Comparable> (value: T, pattern: CountableClosedRange<T> ) -> Bool {
  8. return pattern ~= value
  9. }
  10. func ⊂<T: Comparable> (value: T, pattern: CountableRange<T> ) -> Bool {
  11. return pattern ~= value
  12. }
  13. if 4 ⊂ 1...4 { print("hoge") } // true
  14. if 4 ⊂ 1..<4 { print("???") } // false
Download Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text