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

28 lines
433 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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()