How comaprision operators working?

Nowhere can find information about what type of data is equivalent in ROS another, for example:

0 == “0” or not
0 == false or not
“” = 0 or not
etc.

Or operator “=” in ROS works as the “===” operator in PHP (ie compares fully meet the type and value of the variable)?

It is also not clear what results and what types (including with errors) can be output from the command, and under what circumstances.

For example puzzled over this:

:local DefRouteGW [:tostr 192.168.33.3];
([:find $DefRouteGW “/”] != “”) =======> IS NOT TRUE. WHY?

but

:local DefRouteGW 192.168.33.3;
([:find $DefRouteGW “/”] != “”) =======> IS TRUE. WHY?

How to make sure that the result of the command is blank (“” or empty space or nothing at all or false), or conversely that the result is false and nothing else?

The thing is these things tend to vary from one version to another, which is why they’re not clearly defined anywhere, leading to more bugs and thus changes, which is another reason for no clear definitions, and the vicious cycle continues…

On my main router (v6.9), the “=” works as “===” in PHP, and “!=” works as “!==” in PHP. If type casting is necessary, nil would be returned, rather than bool(false) though.

The reason it doesn’t always work as expected is because the type casting is not as “juggly” as in PHP, making some casts impossible. When a cast is impossible, the casting command would return nil.

In PHP, bool(true) is defined as being equal to int(1) and str(“1”), while bool(false) is int(0), str(“”) and null, and any one of those can be casted to the other.

In RouterOS scripting, bool(true) can only be casted to str(“true”), and bool(false) can only be casted to str(“false”). If you try to cast to any other type, you get nil. The value nil is only equal to itself, and nothing else.

And when introducing type IP into the mix… an IP can be casted to a string with that IP, and nothing else.

:find automatically casts the first argument to a string if it’s not an array, and if it can’t find the second argument in the first, it returns nil.

The conditions is :if and other commands treat nil as being bool(false).