Re: Re: question/suggestion about pass by reference

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Re: question/suggestion about pass by reference

Pan Troglodytes
Right, I've done that before.  But my experience is that this kind of code
can be a bit harder to follow and more prone to mistakes (was the height the
first return value, or was that the width?)

Besides, aren't Array's just objects where the property names are 0, 1, 2,
etc?

On 9/29/06, Doug Lowder <[hidden email]> wrote:

>
> Regarding functions that need to return multiple integers, you could
> always return the values in an Array instead of an object.  I find
> this easier to deal with when object creation would be overkill, and
> there are precedents in AS component classes (Slider.values,
> DataGrid.selectedIndices, etc.).
>
> function returnMultipleInts() : Array {
> var x: Number = 1;
> var y: Number = 2;
> return [x, y];
> }
> ...
> trace( returnMultipleInts()[0] );
> trace( returnMultipleInts()[1] );
>
>
> --- In [hidden email], "Pan Troglodytes"
> <chimpathetic@...> wrote:
> >
> > In my time as a programmer, I've found that I often need a
> function to
> > return more than one result.  In AS3, this means constantly
> creating objects
> > and assigning member variables to them, then returning them.  This
> is
> > especially annoying when I just need to pass back to integer
> values (say an
> > x and a y).  Is this likely to every change in a future revision?
> >
> > Speaking of which, I sent in feedback about one of the livedoc
> pages long
> > ago and never heard anything about it.  It was on pass-by-value
> versus
> > pass-by-reference.  The livedoc is here:
> >
> >
> http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html
> /wwhelp.htm?context=LiveDocs_Parts&file=00001832.html
> >
> > There is a very good summary of why they are wrong here:
> >
> > http://javadude.com/articles/passbyvalue.htm
> >
> >
> > Even though it's java, the same applies to AS.
> >
> > --
> > Jason
> >
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>


--
Jason