[SR-Users] how can string "0" be equal to int 0?

Juha Heinanen jh at tutpro.com
Fri Oct 15 12:44:27 CEST 2010


Andrei Pelinescu-Onciul writes:

> Because "==" works only with arguments of the same type, 0 it's
> autoconverted to "0". The alternative would be to log an error.

andrei,

please log an error, because it is hard to remember this uncommon
comparison rule and seeing an error message would reveal the problem
fast.

> Here are the rules for ==:
> /* if left is string, eval left & right as string and  use string diff.
>  * if left is int eval as int using int diff
>  * if left is undef, look at right and convert to right type
>  */

getting back to the example code, how can i check if value of a var
is int 0?  is there an is_int function?

-- juha



More information about the sr-users mailing list