RosettaCodeData/Task/Call-an-object-method/Nanoquery/call-an-object-method.nanoquery
2023-07-01 13:44:08 -04:00

27 lines
433 B
Text

class MyClass
declare static id = 5
declare MyName
// constructor
def MyClass(MyName)
this.MyName = MyName
end
// class method
def getName()
return this.MyName
end
// static method
def static getID()
return id
end
end
// call the static method
println MyClass.getID()
// instantiate a new MyClass object with the name "test"
// and call the class method
myclass = new(MyClass, "test")
println myclass.getName()