Skip to content

Instantly share code, notes, and snippets.

@isoiphone
Created December 12, 2016 21:57
Show Gist options
  • Save isoiphone/8fcb9b0e5fa1662774c7179150c5f678 to your computer and use it in GitHub Desktop.
Save isoiphone/8fcb9b0e5fa1662774c7179150c5f678 to your computer and use it in GitHub Desktop.
Using one switch statement with multiple lines in each case
class OneBigSwitchExample {
enum Type { case First, Second }
var magic: String = ""
var cool: String = ""
var fast: Bool = false
func foo(type: Type) {
switch type {
case .First:
magic = "dark"
cool = "super"
fast = true
case .Second:
magic = "light"
cool = "super-duper"
fast = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment