change native function num()
num now returns nil if the argument is not a number or numerable string.
This commit is contained in:
parent
05ab4640da
commit
0a407437a4
|
@ -1,4 +1,4 @@
|
|||
# __Nasal Script Language__
|
||||
# __Nasal Scripting Language__
|
||||
|
||||
```C++
|
||||
__ _
|
||||
|
|
|
@ -358,9 +358,14 @@ nasal_ref builtin_int(std::vector<nasal_ref>& local,nasal_gc& gc)
|
|||
nasal_ref builtin_num(std::vector<nasal_ref>& local,nasal_gc& gc)
|
||||
{
|
||||
nasal_ref val=local[1];
|
||||
if(val.type==vm_num)
|
||||
return val;
|
||||
if(val.type!=vm_str)
|
||||
return gc.nil;
|
||||
return {vm_num,val.to_number()};
|
||||
double res=val.to_number();
|
||||
if(std::isnan(res))
|
||||
return gc.nil;
|
||||
return {vm_num,res};
|
||||
}
|
||||
nasal_ref builtin_pop(std::vector<nasal_ref>& local,nasal_gc& gc)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue