Class, setter and getter

Hi Everyone :slight_smile:

Does anyone use this kind of syntax for creating the setter and getter for their custom classes?

public function get foo():dataType {
return _foo;
}
public function set foo(value:dataType):Void {

}

Does the above syntax have any advantages over the bottom one?
I find the top one quite confusing (esp. with the extra space).

public function getFoo():dataType {
return _foo;
}
public function setFoo(value:dataType):Void {

}

Thanks in advance :sure:

I believe the top one (with the space) is implicit.
That means you can reference class variables without actually calling the function.

so like, rather than:

person1.setName(โ€œBobโ€);

you can do this:

person1.name = โ€œBobโ€;

Personally I donโ€™t like it, but I could see uses for it.

Hope this helps. :slight_smile:

Thanks, I get it now :slight_smile: