# `Otera.Range`
[🔗](https://github.com/georgeguimaraes/otera/blob/v0.2.0/lib/otera/range.ex#L1)

The Python `range` object that `range()` gives in a template.

It prints as `range(0, 3)`, has a length, takes an index or a slice, supports `in`, and gives its items when a template iterates over it. A slice of a range is a range.

# `t`

```elixir
@type t() :: %Otera.Range{start: integer(), step: integer(), stop: integer()}
```

# `fetch`

```elixir
@spec fetch(t(), integer()) :: {:ok, integer()} | :error
```

Returns `{:ok, item}` for the item at `index`, which can be negative, or `:error`.

# `member?`

```elixir
@spec member?(t(), term()) :: boolean()
```

Returns true if `item` is an item of `range`. An integer is an item when the arithmetic of the range gives it, and another value when it equals an item.

# `repr`

```elixir
@spec repr(t()) :: String.t()
```

Returns the Python `repr()` of `range`, such as `range(0, 3)` or `range(0, 10, 2)`.

# `size`

```elixir
@spec size(t()) :: non_neg_integer()
```

Returns the number of items of `range`.

# `slice`

```elixir
@spec slice(t(), integer(), integer(), integer()) :: t()
```

Returns `range[start:stop:step]` as a range, where `start` and `stop` are the bounds that `slice.indices` gives for the length of `range`.

# `to_list`

```elixir
@spec to_list(t()) :: [integer()]
```

Returns the items of `range` as a list.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
