Skip to content

1:3 != collect(1:3) #13565

Closed
Closed
@nalimilan

Description

@nalimilan

Is the fact that 1:3 != collect(1:3) intended? I can see in the definition of == that comparisons between Range and Array are explicitly handled to return false, but I can't find a good reason for that.

julia> x = 1:3
1:3

julia> y = collect(x)
3-element Array{Int64,1}:
 1
 2
 3

julia> x == y
false

# And yet:
julia> all(Bool[i == j for (i, j) in zip(x, y)])
true

help?> ==
[...]
  Collections should generally implement == by calling == recursively on all
  contents.
[...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions