Skip to content

Instantly share code, notes, and snippets.

@finestructure
Created May 13, 2022 09:23
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 finestructure/742260260c633c3ec62004f009507306 to your computer and use it in GitHub Desktop.
Save finestructure/742260260c633c3ec62004f009507306 to your computer and use it in GitHub Desktop.
enum Barcode {
case upc(Int, Int, Int, Int)
case qrCode(String)
}
var productBarcode = Barcode.upc(8, 85909, 51226, 3)
productBarcode = .qrCode("ABCDEFGHIJKLMNOP")
switch productBarcode {
case let .upc(numberSystem, manufacturer, product, check):
print("UPC : \(numberSystem), \(manufacturer), \(product), \(check).")
case let .qrCode(productCode):
print("QR code: \(productCode).")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment