I was trying to index using a UnitRange like list[2:end]
then was curious what gonna be happen when my List only has length 1. Thus I began testing with a UnitRange as list which led me to the following strange behaviour.
Version 1.0.2
julia> (1:4)[2:1]
2:1
julia> (1:4)[5:4]
5:4
julia> (1:4)[6:4]
6:5
julia> (1:4)[6:4]
6:5
julia> (1:4)[7:4]
7:6
julia> (1:4)[1:4]
1:4
julia> (1:4)[5:4]
5:4
julia> (1:4)[4:4]
4:4
julia> (1:4)[4]
4
julia> (1:4)[5]
ERROR: BoundsError: attempt to access 4-element UnitRange{Int64} at index [5]
Stacktrace:
[1] throw_boundserror(::UnitRange{Int64}, ::Int64) at .\abstractarray.jl:484
[2] getindex(::UnitRange{Int64}, ::Int64) at .\range.jl:597
[3] top-level scope at none:0
julia> (1:4)[end]
4
julia> (1:4)[5:end]
5:4