Skip to content

Instantly share code, notes, and snippets.

@yannxou
Last active July 13, 2023 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yannxou/1f08b678313ac699cd23d50a9e6541d0 to your computer and use it in GitHub Desktop.
Save yannxou/1f08b678313ac699cd23d50a9e6541d0 to your computer and use it in GitHub Desktop.
Swift: For case let example
import Foundation
enum State {
case idle
case running(speed: Double)
case paused(duration: TimeInterval)
case stopped(reason: String)
}
let states: [State] = [.idle, .paused(duration: 2), .running(speed: 10), .running(speed: 2)]
for case let .running(speed) in states {
print(speed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment