Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Alessandro Crugnola on June 4, 2006 in actionscript

ActionScript 3, ... (rest) parameter, finally!

Yesterday I was reading the latest actionscript 3 documentation on adobe labs and I found that they finally introduced the ... (rest) function's argument, as also described in the ECMA Script 4 specifications.
I say "finally" because it's since I discovered python *args and **kwds function arguments that I pray for them also in actionscript.
In actionscript3 rest parameter is used for example:

public function log(message:String, ... rest):void
{
	logging.text += message + "\n";
	for(var i:uint = 0; i < rest.length; i++)
	{
		logging.text += rest[i] + "\n";
	}
}


log("hello", "spammed", "world");


The reference says about the rest parameter: specifies that a function will accept any number of comma delimited arguments. The list of arguments becomes an array that is available throughout the function body.

Now I just will wait till they will intoduce also the **kwds python equivalent parameter and I will an happy man! :)

Read more here

 

Bookmark and Share

 

Tags: rest parameter 

 

4 comments
we're asking for method's overload since so many years... I dont know if they will put it one day :)
i want to overload methods in AS, why they don't do that... grr.. but rest parameter is a nice one cya
arguments were all the arguments passed to a function, in this way you can define first the n required and typed arguments, and after those the optional arguments
what is difference between rest and arguments? as i know, we can do same process with "argument"


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Type the characters you see in the picture above.





 

TrackBacks

TrackBack URL for this entry: http://www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/99