RosettaCodeData/Task/Call-an-object-method/Nanoquery/call-an-object-method.nanoq...

28 lines
433 B
Plaintext

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()