Created
May 8, 2017 19:26
-
-
Save morozkin/92ac44f2df6a7d93ceee9060ea347720 to your computer and use it in GitHub Desktop.
PatternMatching2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Foo { | |
let name: String | |
} | |
func ~=(pattern: String, value: Foo) -> Bool { | |
return pattern == value.name | |
} | |
let foo = Foo(name: "foo") | |
switch foo { | |
case "foo": | |
print("Foo") | |
default: | |
break | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment