nim-classes
nim-classes copied to clipboard
Example in README does not compile with nim 2.2.4
Looks like a good approach to do Python like OO in Nim.
I tried out the example from the README, but it does not compile with Nim 2.2.4.
First the variable declaration var radius in the Square class must be a float so:
var radius = 5.0
as calculateSize later returns a shape.
Further the repeated let obj = ... lines produce an error as obj is redefined. obj1, obj2 etc would be possible variable names.
Lastly we need to deal with the return value of Shape.defaultSize() as it can't be discarded. So for instance like this:
echo Shape.defaultSize()
there are still a few warnings remaining then but at least the example can be compiled with the current Nim compiler.
Detlef