Last active
August 16, 2016 16:38
-
-
Save meschbach/1f0f793176af712230803997f46b843b to your computer and use it in GitHub Desktop.
Swift Enumeration Matching
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
enum SomeEnum { | |
case .ExampleValue | |
case .CountedCase( someCount : Int ) | |
} | |
func doSomething( state : SomeEnum ){ | |
switch state { | |
case ExampleValue: | |
print("Example") | |
case CountedCase( 0 ): | |
print("0") | |
case let CountedCase( count ): | |
print("Count \(count)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment