deep.is_strict_equal
Defined in module
"deep"from "deep" import is_strict_equalCompares as is_relaxed_equal() does, but numbers are equal only with the same type and the same bits
Parameters
a | any | the first value |
b | any | the second value |
comparers | table|null | an optional table of compare functions, or null, as for is_relaxed_equal optional |
Return value
The value that a compare function or an isEqual() method returns when it decides for a and b themselves, else true or false.
Errors
The same as for is_relaxed_equal.
Notes
Step 1 of is_relaxed_equal is a == b. This function compares the type and the bits instead, so 1 and 1.0 are not equal, 0.0 and -0.0 are not equal, and a NaN is equal to a NaN with the same bits. Other values are equal as with ==: the same object or the same string. Compare functions, len() calls and isEqual() methods are called as for is_relaxed_equal, so a float key of comparers still decides for two floats that are not the same.
Example
from "deep" import is_relaxed_equal, is_strict_equal
from "math" import sqrt
println(is_relaxed_equal([1, 0.0], [1.0, -0.0]), is_strict_equal([1, 0.0], [1.0, -0.0]))
println(is_strict_equal({ id = 1, at = [0.5, 2] }, { id = 1, at = [0.5, 2] }))
let nan = sqrt(-1.0)
println(nan == nan, is_strict_equal([nan], [nan]))Output:
true false
true
false trueSee also
is_relaxed_equal | Compares two values deeply: equal tables and arrays, and instances by their isEqual() method |
copy | Copies tables and arrays deeply, as deep_clone() of underscore.nut does |
| deep | module index |