diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-04-20 22:33:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-21 07:33:56 +0200 |
commit | 7bce1f8578eafffacd599401e709de279528e68b (patch) | |
tree | 471d480325438021d433b2de1f7bdcc1fdf24e19 /doc | |
parent | 8de053d8708d3547edeee8c4846b355a557f1d18 (diff) | |
download | Nim-7bce1f8578eafffacd599401e709de279528e68b.tar.gz |
close #13373 document `(ref Foo)(a: 1)` (#17804)
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual.rst | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/doc/manual.rst b/doc/manual.rst index ea444a0ac..15242cf7c 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -1702,7 +1702,17 @@ has the syntax `T(fieldA: valueA, fieldB: valueB, ...)` where `T` is an `object` type or a `ref object` type: .. code-block:: nim - var student = Student(name: "Anton", age: 5, id: 3) + type + Student = object + name: string + age: int + PStudent = ref Student + var a1 = Student(name: "Anton", age: 5) + var a2 = PStudent(name: "Anton", age: 5) + # this also works directly: + var a3 = (ref Student)(name: "Anton", age: 5) + # not all fields need to be mentioned, and they can be mentioned out of order: + var a4 = Student(age: 5) Note that, unlike tuples, objects require the field names along with their values. For a `ref object` type `system.new` is invoked implicitly. |