Skip to content

Commit

Permalink
close #13373 document (ref Foo)(a: 1) (#17804)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored Apr 21, 2021
1 parent 8de053d commit 7bce1f8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7bce1f8

Please sign in to comment.