Skip to content

The result of an empty intersection of ranges is confusing #40331

@gbaraldi

Description

@gbaraldi

If you call intersectbetween two ranges and the result is empty it returns an empty range of the form 5:4 as in like

julia> a = 1:3
1:3

julia> b = 5:6
5:6

julia> intersect(a,b)
5:4

That can be confusing since you might interpret 5:4 as 5:-1:4
Using Float ranges gives a different result though

julia> a = 30:0.5:42
30.0:0.5:42.0

julia> b = 15:0.5:25
15.0:0.5:25.0

julia> intersect(a,b)
Float64[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    display and printingAesthetics and correctness of printed representations of objects.good first issueIndicates a good issue for first-time contributors to JuliarangesEverything AbstractRange

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions