Skip to content

Instantly share code, notes, and snippets.

@dineshba
Last active May 20, 2018 14:19
Show Gist options
  • Save dineshba/ebee738a584b88f28a27ffe23151375f to your computer and use it in GitHub Desktop.
Save dineshba/ebee738a584b88f28a27ffe23151375f to your computer and use it in GitHub Desktop.
if case .sugar = sugarcane.taste { // if sugarcane.taste is `.sugar` then
print("yummmmy sugarcane") // enters into if
}
if case .salty(let value) = frenchFries.taste { // frenchFries.taste is .salty(10), so it matches
if value < 10 { // the case and assign the value 10 to `value`
print("manageable") // we can use the `value` inside the `if case`
} else {
print("impossible")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment