This way:
# module myclass
# this module is Nim's class; even if not really :)
# this is its static method
proc printSquared*(x: int) = echo x*x
# module test
# to model classes closer, import nothing from it
from myclass import nil
var n = 5
# and now it is
myclass.printSquared(n) # prints 25
Run
- How to write static function inside a type????? calliefrance
- Re: How to write static function inside a type????? moigagoo
- Re: How to write static function inside a type????? LeuGim
