Page 1 of 1

Properties

PostPosted: Thu May 03, 2012 9:13 pm
by DelphiGuy
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.

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

Re: Properties

PostPosted: Fri May 04, 2012 12:17 am
by vmavra
Replace
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.

Re: Properties

PostPosted: Fri May 04, 2012 4:21 am
by DelphiGuy
thanks! yes, i know from the cobra documentation that "value" could be used, but it never occurred to me that it was required.