Skip to content

Instantly share code, notes, and snippets.

@rayman22201
Created October 15, 2018 21:28
Show Gist options
  • Save rayman22201/cb29c89fb06b512c450a1bb9659d9f44 to your computer and use it in GitHub Desktop.
Save rayman22201/cb29c89fb06b512c450a1bb9659d9f44 to your computer and use it in GitHub Desktop.
simple subtype seq example
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