Changes between Version 2 and Version 3 of Property
- Timestamp:
- 11/28/10 11:37:01 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Property
v2 v3 32 32 var __nLife0 = 48 # private access 33 33 34 pro nLife from __nLife 35 }}} 36 37 Can implicitly create initialised backing variable and property in one line like 38 {{{ 39 #!cobra 40 pro nLife = 47 34 pro nLife from __nLife0 35 }}} 36 37 Can implicitly create (a protected) initialised backing variable and property in one line like 38 {{{ 39 #!cobra 40 pro nLife from var = 47 # type inferred from initial value 41 42 # or explicitly specifying type and initial value 43 pro nLife from var as int = 47 41 44 }}} 42 45 … … 44 47 there is a longer syntax variant where either of both the '''get''' and '''set''' accessors can be specified with a block of code to[[BR]] 45 48 store (setter) or generate (getter) the property value. 49 50 {{{ 51 #!cobra 52 var _seed = 21 53 54 # a calculated property 55 pro nLife 56 get 57 return 70 - _seed 58 set 59 require value >0 and value <65 60 _seed = value 61 }}} 46 62 47 63 Properties can have Attributes and the default [wiki:accessModifiers access modifiers] can be overridden explicitly if desired. … … 58 74 59 75 {{{ 60 get <propName> [ as <Type>] [from {var, <backingVariableName>}[= <initValue>] ]61 [has <AttributeList>] 62 [is <accessModifier>] 63 [<DocString>] 64 65 set <propName> [ as <Type>] [from {var, <backingVariableName>}[= <initValue>] ]66 [has <AttributeList>] 67 [is <accessModifier>] 68 [<DocString>] 69 70 pro <propName> [ as <Type>] [from {var, <backingVariableName>}[= <initValue>]]76 get <propName> [from {var, <backingVariableName>} [as <Type>] [= <initValue>] ] 77 [has <AttributeList>] 78 [is <accessModifier>] 79 [<DocString>] 80 81 set <propName> [from {var, <backingVariableName>} [as <Type>] [= <initValue>] ] 82 [has <AttributeList>] 83 [is <accessModifier>] 84 [<DocString>] 85 86 pro <propName> [from {var, <backingVariableName>} [as <Type>] [= <initValue>]] 71 87 [has <AttributeList>] 72 88 [is <accessModifier>]