Skip to content

Instantly share code, notes, and snippets.

@natecook1000
Created March 22, 2015 22:17
Show Gist options
  • Select an option

  • Save natecook1000/16de7a9db4100fcdfebe to your computer and use it in GitHub Desktop.

Select an option

Save natecook1000/16de7a9db4100fcdfebe to your computer and use it in GitHub Desktop.
Enum case matching
enum Test {
case One
case Two
var testDot: String {
switch self {
case .One:
return "One"
case .Two:
return "Two"
}
}
var testLetDot: String {
switch self {
case let .One:
return "One"
case let .Two:
return "Two"
}
}
var testLet: String {
switch self {
case let One:
return "One"
case let Two:
return "Two"
}
}
var testNone: String {
switch self {
case One:
return "One"
case Two:
return "Two"
}
}
}
let two = Test.Two
two.testDot // Two
two.testLetDot // Two
two.testLet // One
two.testNone // Two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment