daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. struct MyValue {
  2.    
  3.     var name: String
  4. }
  5.  
  6. extension MyValue {
  7.    
  8.     static func ~= (pattern: String, value: MyValue) -> Bool {
  9.        
  10.         return value.name.hasPrefix(pattern)
  11.     }
  12. }
  13.  
  14. let value = MyValue(name: "NSString")
  15.  
  16. switch value {
  17.    
  18. case "NS":
  19.     print("Yes")            // Yes
  20.    
  21. default:
  22.     print("NO")
  23. }
RAW Paste Data
Top