Object construction
Objects can also be created with an object construction expression that has the syntax T(fieldA: valueA, fieldB: valueB, …) where T is an object type or a ref object type:
var student = Student(name: "Anton", age: 5, id: 3)
Note that, unlike tuples, objects require the field names along with their values. For a ref object type system.new is invoked implicitly.
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .