RRange.Ruby (REnum v0.8.0)

Summarized all of Ruby's Range functions. Functions corresponding to the following patterns are not implemented

  • When a function with the same name already exists in Elixir.
  • When a method name includes !.
  • %, ==, ===

Link to this section Summary

Functions

Returns the first element of range.

Returns true if list1 == list2.

Returns the last element of range.

Returns Stream that from given range split into by given step.

Executes Enum.each to g given range split into by given step.

Link to this section Functions

Specs

begin(Range.t()) :: integer()

Returns the first element of range.

Examples

iex> RList.begin(1..3)
1
Link to this function

cover?(range, n)

See Enum.member?/2.

See RRange.Ruby.last/1.

Link to this function

eql?(range1, range2)

Specs

eql?(Range.t(), Range.t()) :: boolean()

Returns true if list1 == list2.

Examples

iex> 1..3
iex> |> RList.eql?(1..3)
true

iex> 1..3
iex> |> RList.eql?(1..4)
false

See Kernel.inspect/1.

Specs

last(Range.t()) :: integer()

Returns the last element of range.

Examples

iex> RList.last(1..3)
3
Link to this function

step(arg, step)

Specs

step(Range.t(), integer()) :: Enum.t()

Returns Stream that from given range split into by given step.

Examples

iex> RList.step(1..10, 2)
iex> |> Enum.to_list()
[1, 3, 5, 7, 9]
Link to this function

step(arg, step, func)

Specs

step(Range.t(), integer(), function()) :: :ok

Executes Enum.each to g given range split into by given step.

Examples

iex> RList.step(1..10, 2, &IO.inspect(&1))
iex> |> Enum.to_list()
# 1
# 3
# 5
# 7
# 9
:ok

See Kernel.inspect/1.