Skip to content

Commit 1c01996

Browse files
eksperimentaljosevalim
authored andcommitted
Copyedit Range specs and docs (#10845)
1 parent 103db3a commit 1c01996

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/elixir/lib/range.ex

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Range do
55
66
Ranges are always inclusive and they may have custom steps.
77
The most common form of creating and matching on ranges is
8-
via the `start..stop` and `start..stop//step` notations,
8+
via the [`start..stop`](`../2`) and [`start..stop//step`](`..///3`) notations,
99
defined respectively as the `../2` and `..///3` macros
1010
auto-imported from `Kernel`:
1111
@@ -104,13 +104,13 @@ defmodule Range do
104104
@doc """
105105
Creates a new range.
106106
107-
If first is less than last, the range will be increasing from
108-
first to last. If first is equal to last, the range will contain
107+
If `first` is less than `last`, the range will be increasing from
108+
`first` to `last`. If `first` is equal to `last`, the range will contain
109109
one element, which is the number itself.
110110
111-
If first is more than last, the range will be decreasing from first
112-
to last, albeit this behaviour is deprecated. Instead prefer to
113-
explicitly list the step `new/3`.
111+
If `first` is greater than `last`, the range will be decreasing from `first`
112+
to `last`, albeit this behaviour is deprecated. Therefore, it is advised to
113+
explicitly list the step with `new/3`.
114114
115115
## Examples
116116
@@ -133,7 +133,7 @@ defmodule Range do
133133
end
134134

135135
@doc """
136-
Creates a new range with step.
136+
Creates a new range with `step`.
137137
138138
## Examples
139139
@@ -155,7 +155,7 @@ defmodule Range do
155155
end
156156

157157
@doc """
158-
Returns the size of the range.
158+
Returns the size of `range`.
159159
160160
## Examples
161161
@@ -181,6 +181,7 @@ defmodule Range do
181181
182182
"""
183183
@doc since: "1.12.0"
184+
def size(range)
184185
def size(first..last//step) when step > 0 and first > last, do: 0
185186
def size(first..last//step) when step < 0 and first < last, do: 0
186187
def size(first..last//step), do: abs(div(last - first, step)) + 1

0 commit comments

Comments
 (0)