Added 'new_class' instead of 'new' for the macro.
This commit is contained in:
parent
e3d9812afe
commit
321be06f40
2 changed files with 95 additions and 20 deletions
|
|
@ -6,9 +6,13 @@ These extensions aim to improve the usability of nim in practical applications.
|
|||
Extensions so far include:
|
||||
|
||||
## OOP macro
|
||||
|
||||
This module was modified from the OOP section on the excellent website http://nim-by-example.github.io/
|
||||
|
||||
usage:
|
||||
|
||||
```nim
|
||||
import oop_macro
|
||||
class BaseObject: # inherits from RootObj
|
||||
# attributes/properties
|
||||
var
|
||||
|
|
@ -26,3 +30,8 @@ Extensions so far include:
|
|||
method override_me(argx: float): int=
|
||||
result = int(self.y) + int(argx) + self.x
|
||||
```
|
||||
|
||||
There's also an example in the code that demonstrates the inheritance that can be run by executing:
|
||||
```bash
|
||||
nim c -r oop_macro.nim
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue