jeudi 31 décembre 2015

AS3 method return vs getter return

I understand how both work, and the idea that using getters is the standard or "correct" way of returning objects - but what exactly is the difference? As far as I'm aware, both of the following methods do the exact same thing with an extra word - "get" - added to one of them:

public function object():Object
{
    return _object;
}

public function get object():Object
{
    return _object;
}

Is there any memory/processing differences or anything that would impact the speed or performance of Flash and, if so, can anybody provide benchmarks? Alternatively, is there anything else I should know about this?

Apologies if this has been posted before, I literally can't find anything on the matter and, although both work, I'd like to know if there is any differences I should be aware of.

Aucun commentaire:

Enregistrer un commentaire