You’re right. My test was not done well. So it should probably be: >> return intVal === numVal ? intVal : null;
On May 18, 2016, at 3:40 PM, Andy Dufilie <andy.dufi...@gmail.com> wrote: > (5.3 as int) is null, and "var x:int = null;" becomes zero. > > Sent from my Android > On May 18, 2016 6:54 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >> It seems like it’s 0. >> >> Either way, simply changing it to Number does not seem like a good >> solution. >> >> We probably need to do something like this: >> >> function asInt(value){ >> var intVal:int = int(value);//this should call parseInt() >> var numVal:Number = parseFloat(value) >> return intVal == numVal ? intVal : 0; >> } >> >> On May 18, 2016, at 1:20 PM, Andy Dufilie <andy.dufi...@gmail.com> wrote: >> >>> On May 18, 2016 2:50 AM, "Harbs" <harbs.li...@gmail.com> wrote: >>>> >>>> Isn’t this a behavior change? >>>> >>>> What happens if you do "5.3 as int” in ActionScript? Don’t you get 5? >>>> >>> >>> I just tested this and got null. >> >>