Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
soc authored Dec 23, 2023
1 parent d4fd05f commit a0d305b
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions _languages/rust-struct-initializer-mistake.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ someFunction(.a = 23)
##### Option 3: Let named parameters use the "good" syntax and give variable assignments some "workaround" syntax

Inside a functions argument list, the first level of `=` use is always a named parameter and never a
variable assignment, even if some variable `a` would be in scope.[^2]
variable assignment, even if some variable `a` would be in scope.

```kotlin
// named parameter, and if someFunction's parameter name changes,
Expand All @@ -167,7 +167,3 @@ someFunction(a = 23)
// (which is generally a bad idea):
someFunction(a = { a = 23 })
```


[^1]: Except the tupled version of enums, for which initializers look like function calls again.
[^2]: Also, variable assignment returns `Unit`, so we never have to decide, right? RIGHT?

0 comments on commit a0d305b

Please sign in to comment.