Changes between Version 4 and Version 5 of Methods
- Timestamp:
- 11/07/12 13:39:56 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Methods
v4 v5 1 1 = Methods = 2 3 Methods are blocks of code specific to a class. 4 They can be thought of as providing the actions that a class instance can be told to do. 5 6 Methods can take zero or a number of parameters passed to them and may return a value. 2 7 3 8 Methods within a class are defined using the keyword '''def'''. 4 9 5 If not specified the returnType is void (i.e nothing returned) and the [wiki:AccessModifiers access modifiers] are '''public, virtual'''[[BR]]10 If not specified the returnType of a method is void (i.e nothing returned) and the [wiki:AccessModifiers access modifiers] are '''public, virtual'''. 6 11 7 12 Like variables, if the name is prefixed with an '''_''' its access modifier defaults to ''protected'' and it is directly accessable from within the class method code.[[BR]] … … 9 14 10 15 Without that prefix on the name of the method the accessType is ''public, virtual'' and 11 it must be accessed from within method code by prefixing the name with either '''this.''' or just '''.''' .[[BR]]16 it must be accessed from within method code by prefixing the name with either '''this.''' or just '''.''' (dot) .[[BR]] 12 17 13 18 == Method Grammar == … … 22 27 23 28 24 === Method ParamList ===29 === Method !ParamList === 25 30 26 31 A parameter list is a comma separated list of name (and optionally type and parameter description modifier) specifications … … 40 45 41 46 42 If <Type> is unspecified it is treated as dynamic?[[BR]]47 If <Type> is unspecified it is defaulted to and treated as dynamic.[[BR]] 43 48 44 49 … … 74 79 a baseclass constructor). 75 80 76 If an init method is not specified the compiler runtime generates a noArg constructor that does nothing .81 If an init method is not specified the compiler runtime generates a noArg constructor that does nothing (changed - this was original behaviour, now an init method must be explicitly provided). 77 82 78 83 Constructor chaining can be done to another constructor in the same class (usually with a different number or Type of args)