Methods - Saskyc/Lunacity-Wiki GitHub Wiki
What is method?
Definition
accessor method Name():
end
Returning value
Definition:
- This although throws exception as no value is thrown.
accessor method returns Type Name():
end
Example:
public method returns Int GetOne():
return 1
end
Arguments
Definition:
accessor method Name(type name, type anotherName, type thirdName):
end
Example:
public method returns Int PowerTwo(Int n):
return n * n;
end
Creates
Creates is special method that allocates targeted class into new object.
- Usually defined inside object that is allocated by calling this method.
- [Constructor] is used for runtime, so it map
newkeyword toIpsumclass resulting innew Ipsum(int)
Definition
public static method creates TargetedClass Name(args):
end
Example
module Lorem:
public class Ipsum:
public int Dolor
[Constructor]
public static method creates Ipsum Ctor(int dolor):
self.Dolor = dolor
return self
end
end
end