Question

I've found two very strange pieces of code in PureMVC's documentation:

public function get resultEntry( index:int ) : SearchResultVO
{
    return searchResultAC.getItemAt( index ) as SearchResultVO;
}

and bit later:

var item:SearchResultVO = searchProxy.resultEntry( 1 );

(found in Best Practices [English], bottom of page 38 and top of page 39)

I've always thought that getters must not accept a parameter (and FDT indeed tells me that "Parameters for getters are not allowed"), so I wonder what's going on here.

Is that just an unfortunate typo (meant to be simply a normal function without the "get") or some hidden feature/voodoo?

Was it helpful?

Solution

Normally the only way to achieve this is as follows:

public function getResultEntry( index:int ) : SearchResultVO
{
    return searchResultAC.getItemAt( index ) as SearchResultVO;
}

The reason is because get is reserved ActionScript keyword. It will in fact expose your function as a public property and expects a predefined format.

It occurs in both strict an non strict type checking modus, so I am guessing that it is a typo in the PureMVC documentation :)

I suggest that you write an email to Cliff Hall then :P

Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top