Deviopath › Swift

Traffic Light

Medium · Enums

An enum with associated values is overkill here: a simple enum red, yellow, green. next advances red→green→yellow→red. Write next(_:) that takes and returns the name as a string.

Next: Optional Chaining