is(x,y)

is(x, y) -> Bool ===(x,y) -> Bool ≡(x,y) -> Bool

Determine whether x and y are identical, in the sense that no program could distinguish them. Compares mutable objects by address in memory, and compares immutable objects (such as numbers) by contents at the bit level. This function is sometimes called egal.

Examples

  1. Check if two objects are identical:

    julia> is(10, 10)
    true

    This example demonstrates that the two integer objects 10 are identical.

  2. Compare strings for identity:

    julia> is("hello", "hello")
    true

    It checks if the two string objects "hello" are identical.

  3. Identical arrays:

    julia> arr1 = [1, 2, 3];
    julia> arr2 = [1, 2, 3];
    julia> is(arr1, arr2)
    false

    In this example, the is function returns false because arr1 and arr2 are different array objects, even though they have the same content.

  4. Immutable objects equality:
    julia> is(3.14, 3.1400000000000001)
    false

    The is function compares immutable objects at the bit level. In this example, the two floating-point numbers are not considered identical due to slight differences in their binary representation.

It's worth noting that === and are aliases for the is function, so they can be used interchangeably.

Please remember that is compares mutable objects by memory address and immutable objects by bit-level contents. Avoid using is for comparing mutable objects' content as it may not give the expected results.

If you encounter any issues or unexpected behavior when using is, ensure that you are comparing the correct types and objects.

See Also

all, all!, angle, any, any!, falses, ifelse, is, isinf, isinteger, isnan, isperm, ispow2, isreal, trues,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: