Skip to content

Commit d35d60f

Browse files
authored
Add typespecs and docs to 'Range' module (#12953)
1 parent 9c0fa3c commit d35d60f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/elixir/lib/range.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ defmodule Range do
273273
274274
"""
275275
@doc since: "1.14.0"
276+
@spec shift(t, integer) :: t
276277
def shift(first..last//step, steps_to_shift)
277278
when is_integer(steps_to_shift) do
278279
new(first + steps_to_shift * step, last + steps_to_shift * step, step)
@@ -364,6 +365,7 @@ defmodule Range do
364365
365366
"""
366367
@doc since: "1.15.0"
368+
@spec split(t, integer) :: {t, t}
367369
def split(first..last//step = range, split) when is_integer(split) do
368370
if split >= 0 do
369371
split(first, last, step, split)
@@ -392,8 +394,17 @@ defmodule Range do
392394

393395
@doc """
394396
Converts a range to a list.
397+
398+
## Examples
399+
400+
iex> Range.to_list(0..5)
401+
[0, 1, 2, 3, 4, 5]
402+
iex> Range.to_list(-3..0)
403+
[-3, -2, -1, 0]
404+
395405
"""
396406
@doc since: "1.15.0"
407+
@spec to_list(t) :: list(integer)
397408
def to_list(first..last//step)
398409
when step > 0 and first <= last
399410
when step < 0 and first >= last do

0 commit comments

Comments
 (0)