# range

range(start, [step], length)

Construct a range by length, given a starting value and optional step (defaults to 1).

## Examples

Construct a range by length, given a starting value and optional step (defaults to 1):

1. Generate range with default step:

``````julia> r = range(1, length=5)
1:1:5``````

This example generates a range starting from 1 with a length of 5 and a default step of 1.

2. Generate range with a specified step:

``````julia> r = range(0, step=0.5, length=5)
0.0:0.5:2.0``````

It generates a range starting from 0 with a step of 0.5 and a length of 5.

3. Generate range with negative step:

``````julia> r = range(10, step=-2, length=5)
10:-2:2``````

This example generates a range starting from 10 with a step of -2 and a length of 5.

4. Generate range with non-integer values:
``````julia> r = range(0.1, step=0.2, length=5)
0.1:0.2:1.1``````

It generates a range starting from 0.1 with a step of 0.2 and a length of 5.

Common mistake example:

``````julia> r = range(1, step=0, length=5)
ERROR: ArgumentError: Step size cannot be zero``````

In this example, the step size provided is zero, which is an invalid argument. Make sure to provide a non-zero step size to avoid this error when using the `range` function.