Skip to content

Commit

Permalink
Add examples for range() (JuliaLang#27012)
Browse files Browse the repository at this point in the history
* Add examples for range()

In case I'm not the only one confused by the changes to `range()`, I'm trying to add a few examples here.
  • Loading branch information
cormullion authored and fredrikekre committed May 7, 2018
1 parent 74af878 commit 989de79
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ If `length`, `stop`, and `step` are all specified, they must agree.
If `length` and `stop` are provided and `step` is not, the step size will be computed
automatically such that there are `length` linearly spaced elements in the range.
# Examples
```jldoctest
julia> range(1, length=100)
1:100
julia> range(1, stop=100)
1:100
julia> range(1, step=5, length=100)
1:5:496
julia> range(1, step=5, stop=100)
1:5:96
```
"""
range(start; length::Union{Integer,Nothing}=nothing, stop=nothing, step=nothing) =
_range(start, step, stop, length)
Expand Down

0 comments on commit 989de79

Please sign in to comment.