Forums

Properties

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Properties

Postby DelphiGuy » Thu May 03, 2012 9:13 pm

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
DelphiGuy
 
Posts: 116

Re: Properties

Postby vmavra » Fri May 04, 2012 12:17 am

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.
vmavra
 
Posts: 15

Re: Properties

Postby DelphiGuy » Fri May 04, 2012 4:21 am

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


Return to Discussion

Who is online

Users browsing this forum: No registered users and 6 guests

cron