Changes between Version 4 and Version 5 of Variables
- Timestamp:
- 01/14/14 11:25:10 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Variables
v4 v5 34 34 35 35 {{{ 36 #!cobra 36 37 s = "name:" # s is a String since thats what it is assigned from 37 38 greet = 'hello ' + 'Mike.' # also a String since the assignment is a (String) expression … … 50 51 Local variables of Reference types should generally be assigned to, to create and type them. 51 52 {{{ 53 #!cobra 52 54 s as String # generates a compiler error 53 55 # needs to be … … 71 73 72 74 {{{ 75 #!cobra 73 76 space = 32_u8 74 77 ispace as int32 = space … … 97 100 98 101 {{{ 102 #!cobra 99 103 class VarEG 100 104 var count = 0 # type inferred from initial value (int32) … … 139 143 140 144 {{{ 145 #!cobra 141 146 # Initializer/Ctor 142 147 cue init( age as int, name as String) … … 153 158 }}} 154 159 155 In the initializer, instance variable _name is nowinitialised, [[BR]]156 _definition is nil but thats allowed since its declared nilable.160 By the end of the initializer, instance variable _name is fully initialised, [[BR]] 161 _definition (VarEg._definition) is nil but thats allowed since its declared nilable. 157 162 158 163 … … 169 174 170 175 {{{ 171 176 #!cobra 172 177 # call to create VarEg instance 173 178 t = VarEG( 157, 'hops') … … 194 199 195 200 {{{ 196 201 #!cobra 197 202 t = VarEG( 492, 'hops') 198 203 oldDefn = t.defn # local var oldDefn <- 'No defn' … … 214 219 215 220 {{{ 221 #!cobra 216 222 # Note that nItems is incremented in the initializer so it has a count of the 217 223 # number of instances made