@@ -5,7 +5,7 @@ defmodule Range do
5
5
6
6
Ranges are always inclusive and they may have custom steps.
7
7
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,
9
9
defined respectively as the `../2` and `..///3` macros
10
10
auto-imported from `Kernel`:
11
11
@@ -104,13 +104,13 @@ defmodule Range do
104
104
@ doc """
105
105
Creates a new range.
106
106
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
109
109
one element, which is the number itself.
110
110
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`.
114
114
115
115
## Examples
116
116
@@ -133,7 +133,7 @@ defmodule Range do
133
133
end
134
134
135
135
@ doc """
136
- Creates a new range with step.
136
+ Creates a new range with ` step` .
137
137
138
138
## Examples
139
139
@@ -155,7 +155,7 @@ defmodule Range do
155
155
end
156
156
157
157
@ doc """
158
- Returns the size of the range.
158
+ Returns the size of ` range` .
159
159
160
160
## Examples
161
161
@@ -181,6 +181,7 @@ defmodule Range do
181
181
182
182
"""
183
183
@ doc since: "1.12.0"
184
+ def size ( range )
184
185
def size ( first .. last // step ) when step > 0 and first > last , do: 0
185
186
def size ( first .. last // step ) when step < 0 and first < last , do: 0
186
187
def size ( first .. last // step ) , do: abs ( div ( last - first , step ) ) + 1
0 commit comments