Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SteveRohrlack/8fce263d163835c9bcdd244a01d7aa4c to your computer and use it in GitHub Desktop.
Save SteveRohrlack/8fce263d163835c9bcdd244a01d7aa4c to your computer and use it in GitHub Desktop.
swift enumerations with named associated values
enum MonitorType {
case widescreen(size: Int, refreshRate: Int, manufacturer: String)
case ultrawidescreen(size: Int, refreshRate: Int, manufacturer: String)
}
let widescreenMonitor: MonitorType = .widescreen(size: 26, refreshRate: 6, manufacturer: "Apple")
let ultraWidescreenMonitor: MonitorType = .ultrawidescreen(size: 28, refreshRate: 6, manufacturer: "Eizo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment