-
-
Save rayman22201/cb29c89fb06b512c450a1bb9659d9f44 to your computer and use it in GitHub Desktop.
simple subtype seq example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Person = ref object of RootObj | |
name*: string # the * means that `name` is accessible from other modules | |
age: int # no * means that the field is hidden from other modules | |
Student = ref object of Person # Student inherits from Person | |
id: int # with an id field | |
var | |
student: Student | |
person: Person | |
# object construction: | |
student = Student(name: "Anton", age: 5, id: 2) | |
var school : seq[Person] = @[] | |
school.add(student) | |
echo school[0][] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment