I’d rather would have the ability of overloading enum cases:
enum MyEnum {
case a
case a(Int)
case a(label: Int)
case a(Double)
}
I don’t know how enums work internally, but I spotted a bug recently where the
compiler does not allow to declare a function with the same name as an enum
case.
SR–3256
I think this is a side effect of this proposal
https://github.com/apple/swift-evolution/blob/master/proposals/0036-enum-dot.md
--
Adrian Zubarev
Sent with Airmail
Am 29. November 2016 um 14:48:30, Steve Prescott via swift-evolution
([email protected]) schrieb:
Has there been any discussion of REQUIRING names for associated types in an
enum?
e.g.,
Current = “case error (String, Int)” // No names
Proposed = “case error (errorString: String, errorCode: Int)” // Has names
I know that Swift allows this today — optionally. To me, it seems that
requiring the parameter names would be more consistent with func syntax. The
current syntax (defaulting to no names) leads to declaration of vars that look
C-like, to me:
let myResult = Result.error (“It failed”, -999)
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution