對於字符串和對象類型,我可以將默認參數設置爲null以指示它未由調用者設置。在flex3中有沒有一種機制可以爲數字類型做同樣的事情?如何在Flex3中指定未設置的Number類型的默認參數?
因此,例如: 公共職能myMethod的(STRINGVAR:字符串=空,ObjectVar:對象= NULL,numberVar:號碼) { ... }
我可以做到以下幾點,但它只是感覺醜陋
public function myMethod(numberVarObj:Object=null)
{
var numberVarSet:Boolean=true;
if(numberVarObj == null) {
numberVarSet = false;
}
and then everywhere I want to use numberVar I can check for numberVarSet and cast as a Number.