Primitive data types are passed by value
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var effort:Number = 110;
var trimmedPercentage:Number = limitPercentage(effort);
trace(effort, "%");
trace(trimmedPercentage, "%");
}
function limitPercentage(percentage:Number):Number {
percentage = Math.min(percentage, 100);
percentage = Math.max(percentage, 0);
return percentage;
}
}
}
Related examples in the same category