-
Notifications
You must be signed in to change notification settings - Fork 5
Static Classes and Methods
Christopher Diggins edited this page Aug 13, 2023
·
3 revisions
Plato has no static keyword. Classes that have no fields are automatically treated as if they are static classes.
Methods are treated as static methods automatically if they do not have any reference to a member field or non-static method.
In Plato all methods that are inferred to be static are automatically made into extension methods. An extension method is available to be called on an object as if it were defined on the class itself.
library UnitOperations
{
Radians(x: Numbers): Angle => x;
Turns(x: Number): Angle => x * 2 * 3.14159265635897;
Degrees(x: Number) => Turns(x / 360.0);
Grads(x: Number) => Turns(d / 400.0);
Turns(a: Angle): Number => a * 2 * Math.PI;
Degrees(a: Angle): Number => a.Turns * 360;
Grads(a: Angle): Number => a.Turns * 400;
}