mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: support short struct update syntax {...ident,
(#8613)
This commit is contained in:
@ -1633,6 +1633,8 @@ Only more complex types such as arrays and maps may be modified.
|
||||
Use `user.register()` or `user = register(user)`
|
||||
instead of `register(mut user)`.
|
||||
|
||||
#### Struct update syntax
|
||||
|
||||
V makes it easy to return a modified version of an object:
|
||||
|
||||
```v
|
||||
@ -1644,7 +1646,7 @@ struct User {
|
||||
|
||||
fn register(u User) User {
|
||||
return {
|
||||
u |
|
||||
...u
|
||||
is_registered: true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user