|
|
|
|
|
by hawflakes
1628 days ago
|
|
> enum case with parameters
Ah, this is a language feature of enums in Swift. Swift enums allow you to keep associated values with a specific case and you need to unpack them with a `let` when dealing with that value. E.g. enum Animal {
case lion
case tiger
case bear
case ohMy(Int)
}
The case `ohMy(Int)` means that it has an associated value so when you want to get at it from a variable, say: var a:Animal
switch a {
case .ohMy(let value):
// do something with `value`
...
}
|
|