Skip to content

Conversation

@udohjeremiah
Copy link
Contributor

@udohjeremiah udohjeremiah commented Oct 1, 2022

The doc says:

help?> StepRange

  StepRange{T, S} <: OrdinalRange{T, S}

  Ranges with elements of type T with spacing of type S. The step between each
  element is constant, and the range is defined in terms of a start and stop of
  type T and a step of type S. Neither T nor S should be floating point types. The
  syntax a:b:c with b > 1 and a, b, and c all integers creates a StepRange.

The part where it says:

The syntax a : b : c with b > 1 and a, b, and c all integers creates a StepRange.

is very misleading and confusing because b = 1 creates a StepRange:

julia> typeof(1:1:5)
StepRange{Int64, Int64}

And even b < 1 creates a StepRange as well:

julia> typeof(5:-1:1)
StepRange{Int64, Int64}

julia> collect(5:-1:1)
5-element Vector{Int64}:
 5
 4
 3
 2
 1

So I think the intended action of that word is to say: "zero as a step is not allowed.". If that's not it, then the b>0 or b!= 0 part can just be removed all together since the error message even tells that:

julia> 1:0:5
ERROR: ArgumentError: step cannot be zero

@LilithHafner LilithHafner added docs This change adds or pertains to documentation ranges Everything AbstractRange labels Oct 2, 2022
@LilithHafner LilithHafner changed the title fix typo confusion error on StepRange fix error in StepRange documentation Oct 2, 2022
@LilithHafner LilithHafner merged commit fde48ae into JuliaLang:master Oct 2, 2022
@LilithHafner
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs This change adds or pertains to documentation ranges Everything AbstractRange

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants