Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- # An object which will be allocated on stack
- Animal = object
- name: string
- legs: int
- # Non ref objects (stack objects) cannot be mutated
- # inside methods
- proc setName(a: Animal, name: string) =
- a.name = name
- var dog = Animal(name: "shadow", legs: 4)
- dog.name = "lucy"
- dog.setName("jimmy")
- # Object types can be converted to string with $
- echo $dog
Add Comment
Please, Sign In to add comment