Hi
I will like to make the proposal to allow a switch let, similar to a if let,
this will avoid having to repeat every variable name
enum Barcode {
case UPCA(Int, Int, Int, Int)
case QRCode(String)
}
var productBarcode = Barcode.UPCA(8, 85909, 51226, 3)
//current:
switch productBarcode {
case .UPCA(let numberSystem, let manufacturer, let product, let check):
print("UPC-A: \(numberSystem), \(manufacturer), \(product), \(check).")
case .QRCode(let productCode):
print("QR code: \(productCode).")
}
//suggestion:
switch let p = productBarcode {
case .UPCA:
print("UPC-A: \(p.numberSystem), \(p.manufacturer), \(p.product),
\(p.check).")
case .QRCode:
print("QR code: \(p.productCode).")
}_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution