Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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")
- }
- }
Add Comment
Please, Sign In to add comment