Minor changes to oop macro
This commit is contained in:
parent
20227f4866
commit
08dd43fc9d
1 changed files with 4 additions and 2 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
---
|
---
|
||||||
title: OOP Macro
|
title: OOP Macro
|
||||||
---
|
---
|
||||||
<!--- Thanks to fowl for creating this page -->
|
<!--- Thanks to fowl for creating this page, filwit for fixing some oddities -->
|
||||||
|
|
||||||
# OOP Macro
|
# OOP Macro
|
||||||
This is the code that we currently must write to use OOP in nimrod:
|
This is the code that we currently must write to use OOP in Nimrod:
|
||||||
|
|
||||||
```nimrod
|
```nimrod
|
||||||
type Animal = ref object of TObject
|
type Animal = ref object of TObject
|
||||||
|
|
@ -38,6 +38,8 @@ class Cat of Animal:
|
||||||
method vocalize: string = "meow"
|
method vocalize: string = "meow"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To get that nice notation, we can use a macro:
|
||||||
|
|
||||||
```nimrod
|
```nimrod
|
||||||
import macros
|
import macros
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue