Skip to content

Commit

Permalink
Merge pull request #17616 from JuliaLang/teh/oneto_docstring
Browse files Browse the repository at this point in the history
Add docstring for Base.OneTo [ci skip]
  • Loading branch information
tkelman committed Jul 26, 2016
2 parents 9c0c763 + fe45425 commit 9fbe3b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ unitrange_last{T}(start::T, stop::T) =
ifelse(stop >= start, convert(T,start+floor(stop-start)),
convert(T,start-one(stop-start)))

"""
Base.OneTo(n)
Define an `AbstractUnitRange` that behaves like `1:n`, with the added
distinction that the lower limit is guaranteed (by the type system) to
be 1.
"""
immutable OneTo{T<:Integer} <: AbstractUnitRange{T}
stop::T
OneTo(stop) = new(max(zero(T), stop))
Expand Down
6 changes: 6 additions & 0 deletions doc/stdlib/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ Mathematical Operators
Construct a range by length, given a starting value and optional step (defaults to 1).

.. function:: Base.OneTo(n)

.. Docstring generated from Julia source
Define an ``AbstractUnitRange`` that behaves like ``1:n``\ , with the added distinction that the lower limit is guaranteed (by the type system) to be 1.

.. _==:
.. function:: ==(x, y)

Expand Down

0 comments on commit 9fbe3b5

Please sign in to comment.