This is only a syntactic difference. Consequently, x is bound to the enum case's associated value whether you write let .someCase(x) or .someCase(let x) as the pattern of the switch case.
.someCase(let x)
This is an enum case pattern, with a value-binding pattern (let x) within it. Within the value-binding pattern, there is an identifier pattern x. As an abstract syntax tree, it looks like this:
enum case pattern
|
value-binding pattern
|
identifier pattern
let .someCase(x)
In this case, the value-binding pattern is the root of the tree instead:
value-binding pattern
|
enum case pattern
|
identifier pattern
Note that the syntax for value-binding patterns is very flexible, any kind of pattern can follow the keyword let/var.
value-binding-pattern ::= 'let' pattern | 'var' pattern
According to the value-binding patterns section of the Swift guide,
Identifiers patterns within a value-binding pattern bind new named variables or constants to their matching values.
In both cases, the identifier pattern is nested within the value-binding pattern, directly or indirectly. Therefore, x is bound to the matched associated value in the same way.
It might seem like writing let first thing in the pattern is always a good idea since it binds all the identifiers to the newly matched values in one go. But sometimes you don't actually want to bind everything:
enum Foo {
case someCase(Int, Int, Int)
}
func someFunction(someParameter: Int, foo: Foo) {
switch foo {
// if you wrote "let .someCase(someParameter, y, z)" here,
// then someParameter would be bound to the associated value, rather than
// the function's parameter!
case .someCase(someParameter, let y, let z):
break
default:
break
}
}