2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,29 @@
SpecialObject {
classvar a = 42, <b = 0, <>c; // Class variables. 42 and 0 are default values.
var <>x, <>y; // Instance variables.
// Note: variables are private by default. In the above, "<" creates a getter, ">" creates a setter
*new { |value|
^super.new.init(value) // constructor is a class method. typically calls some instance method to set up, here "init"
}
init { |value|
x = value;
y = sqrt(squared(a) + squared(b))
}
// a class method
*randomizeAll {
a = 42.rand;
b = 42.rand;
c = 42.rannd;
}
// an instance method
coordinates {
^Point(x, y) // The "^" means to return the result. If not specified, then the object itself will be returned ("^this")
}
}

View file

@ -0,0 +1,3 @@
SpecialObject.randomizeAll;
a = SpecialObject(8);
a.coordinates;

View file

@ -1,22 +0,0 @@
MyClass {
classvar someVar, <another, <>thirdVar; // Class variables.
var <>something, <>somethingElse; // Instance variables.
// Note: variables are private by default. In the above, "<" enables getting, ">" enables setting
*new {
^super.new.init // constructor is a class method. typically calls some instance method to set up, here "init"
}
init {
something = thirdVar.squared;
somethingElse = this.class.name;
}
*aClassMethod {
^ someVar + thirdVar // The "^" means to return the result. If not specified, then the object itself will be returned ("^this")
}
anInstanceMethod {
something = something + 1;
}
}