One way is

 

Rest.unshift(msg);

Rest.unshift(Level.DEBUG)

doLog.apply(null, Rest)

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Collin Peters
Sent: Thursday, May 24, 2007 8:45 PM
To: [email protected]
Subject: [flexcoders] Passing the ...(rest) parameter to another
function

 

Is it possible to properly pass the ...(rest) parameter to another
function without it being converted to a single element array?

Example:

public static function debug(msg:String, ...rest)
{
doLog(Level.DEBUG, msg, rest);
}
public static function error(msg:String, ...rest)
{
doLog(Level.ERROR, msg, rest);
}

public static function send(msgLevel:int, msg:String, ...rest)
{
//rest is always a single element array here!!!!
var actualArgs:Array = rest[0];
}

I am trying to implement a logging framework that will do both
parameter substitution in the form of:
Logger.debug("substitute {0} and {1}", "here", "here")"
and also accept an object:
Logger.debug("Dump", obj);

I cannot get the substitution to perform correctly. It always outputs
"substitute here,here and ({1}) "

Regards,
Collin

 

Reply via email to