std/with support field assign (#14484)
* std/with support filed assign * add changelog * add support x.dup.with * add example * revert support x.dup.with; add example * update changelog; fix assignment in parameter * Update changelog.md * add example for assignment in parameter * Remove colon style assign Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
parent
957bf15a08
commit
ba042af9cc
4 changed files with 59 additions and 12 deletions
15
changelog.md
15
changelog.md
|
|
@ -148,6 +148,21 @@
|
|||
- Added `deques.toDeque`, which creates a deque from an openArray. The usage is
|
||||
similar to procs such as `sets.toHashSet` and `tables.toTable`. Previously,
|
||||
it was necessary to create an empty deque and add items manually.
|
||||
|
||||
- `std/with`, `sugar.dup` now support object field assignment expression:
|
||||
```nim
|
||||
import std/with
|
||||
|
||||
type Foo = object
|
||||
x, y: int
|
||||
|
||||
var foo = Foo()
|
||||
with foo:
|
||||
x = 10
|
||||
y = 20
|
||||
|
||||
echo foo
|
||||
```
|
||||
|
||||
## Language changes
|
||||
- The `=destroy` hook no longer has to reset its target, as the compiler now automatically inserts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue