Closed mattyohe closed 7 years ago
I'm partial to A. until I am forced in a mixed case to use E.
I prefer B. Consider something like this:
enum Foo {
case bar
case baz(Bool)
}
Using let
only makes sense in the context of cases that actually have associated values, so it feels more accurate to move that into the case itself.
case .baz(let qui)
@hpwooten Ah, so you point to cases I didn't consider.
enum Foo {
case bar
case baz(Bool)
case fred(Bool)
}
F.
case (.bar, .baz(let quux))
G.
case let (.bar, .baz(quux))
H.
case let (.bar, .baz(quux), .fred(corge))
I.
case (.bar, .baz(let quux), .fred(let corge))
J.
case (.bar, .baz(let quux), .fred(var corge))
Consistent with my previous comment, I'd go with G or H until the mixed binding case where I'd use J
After some in-person conversations, and some folks on Slack, I'm now being convinced against my initial thoughts. That is, prefer B, D, E, F, I, J.
Reason being, I'm really more looking for a simple rule to follow when this comes up and just simply stating, "place the introducer next to the variable being bound" is much simpler than trying to describe any other method.
Given:
Single binding:
A.
B.
Multiple binding: C.
D.
Mixed multiple binding: E.