2024-10-16 18:07:41 -07:00
|
|
|
in Org:RosettaCode
|
2023-07-01 11:58:00 -04:00
|
|
|
type MyClass ^|we are defining a new data type and entering in its static context|^
|
2024-10-16 18:07:41 -07:00
|
|
|
fun method ← void by block do writeLine("static method called") end
|
2023-07-01 11:58:00 -04:00
|
|
|
model ^|we enter the instance context|^
|
2024-10-16 18:07:41 -07:00
|
|
|
fun method ← void by block do writeLine("instance method called") end
|
2023-07-01 11:58:00 -04:00
|
|
|
end
|
|
|
|
|
type CallAnObjectMethod
|
2024-10-16 18:07:41 -07:00
|
|
|
var myInstance ← MyClass() ^|creating an instance|^
|
2023-07-01 11:58:00 -04:00
|
|
|
myInstance.method()
|
2024-10-16 18:07:41 -07:00
|
|
|
myInstance["method"]() ^|using symbolic references|^
|
2023-07-01 11:58:00 -04:00
|
|
|
MyClass.method()
|
2024-10-16 18:07:41 -07:00
|
|
|
var("Org:RosettaCode:MyClass", "method")() ^|using symbolic references|^
|