class DoSomething
def main
z = GlobalVars()
z.ticksPerSecond = 3
print z.ticksPerSecond
class GlobalVars
var _ticksPerSecond as decimal
pro ticksPerSecond as decimal
get
return _ticksPerSecond
set
_ticksPerSecond = .ticksPerSecond
Forums
Properties
3 posts
• Page 1 of 1
Properties
what goofy thing am i doing to prevent assigning 3 to the member property of the z instance? code prints out "0", but i expect it to print "3". thanks.
- DelphiGuy
- Posts: 116
Re: Properties
Replace
with
and it will work. If you didn't know already, "value" is a special keyword that acts as an implicit parameter for the set accessor.
set
_ticksPerSecond = .ticksPerSecond
with
set
_ticksPerSecond = value
and it will work. If you didn't know already, "value" is a special keyword that acts as an implicit parameter for the set accessor.
- vmavra
- Posts: 15
Re: Properties
thanks! yes, i know from the cobra documentation that "value" could be used, but it never occurred to me that it was required.
- DelphiGuy
- Posts: 116
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 48 guests