AS3文檔指出,如果將字符串傳遞給parseInt而不是數字,它將返回NaN。然而,當我嘗試比較NaN編譯器給了我以下錯誤: Warning: 1098: Illogical comparison with NaN. This statement always evaluates to false.
的說法是真的。與NaN相比將始終返回false。我如何與NaN進行比較來檢測是否解析了NaN?
我剛剛發現了一個bug在我的節目一定數量的操作,我得到一個FloatDomainError (NaN) 於是我開始記錄與傳遞的數量: if(metric.is_a?(Numeric))
self.metric = metric
else
LOGGER.warn("metriC#{metric} is not a number")
self.metric=0
end