class1.class2(1)
Code: Select all
; This example requires the FunctionObject class above in order to work.
class class1 {
class class2 extends FunctionObject {
Call(self, a) {
MsgBox % a
}
}
}
class FunctionObject {
__Call(method, args*) {
if (method = "")
return this.Call(args*)
if (IsObject(method))
return this.Call(method, args*)
}
}
- Boilerplate is unfriendly to newbies. Why 2 classes?
- Function Objects should be first-class. This boilerplate demonstrates they are not.
- Newbies start out using classes as more of a tool to organize their functions. By letting them replace their functions with function objects, they can more easily understand classes.