Skip to content

Instantly share code, notes, and snippets.

@danielctull
Forked from PeteC/gist:b034ec34ce654c2e41b1
Created August 27, 2014 09:52
Show Gist options
  • Save danielctull/f20fe5e1aaeaf6c08cd6 to your computer and use it in GitHub Desktop.
Save danielctull/f20fe5e1aaeaf6c08cd6 to your computer and use it in GitHub Desktop.
enum MyEnum {
case StateA
case StateB
}
let enumValueA = MyEnum.StateA
let enumValueB = MyEnum.StateB
if enumValueA == enumValueB {
println("Same")
}
else {
println("Different")
}
enum AnotherEnum {
case StateA
case StateB(Int)
}
let anotherEnumValueA = AnotherEnum.StateA
let anotherEnumValueB = AnotherEnum.StateB(1)
if anotherEnumValueA == anotherEnumValueB { // Compiler error
println("Same")
}
else {
println("Different")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment