# Using step in the range function

**URL:** <https://discourse.julialang.org/t/using-step-in-the-range-function/134011>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 20, 2025, 4:46pm UTC](https://discourse.julialang.org/t/using-step-in-the-range-function/134011 "2025-11-20T16:46:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Queenvictoria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/queenvictoria/32/218740_2.png) [@Queenvictoria](https://discourse.julialang.org/u/Queenvictoria)\
**Post date:** [November 20, 2025, 4:46pm UTC](https://discourse.julialang.org/t/using-step-in-the-range-function/134011/1 "2025-11-20T16:46:19Z")

</div>

I’m trying to understand how the range function works. Because I know that you can define each value. (the examples are from documentation)

```julia-auto
range(stop=10, step=1, length=5)

```

And I know that you can forgo some of the keywords.

```julia-auto
range(1, 100, step=5)

```

^^^This works.

```julia-auto
range(1, 5, 5)

```

This works too, where the input is assumed to be **start, stop, length**.  
But I’ve been unable to use step in this function without defining it. Is it possible to do so?  
Also is it better to define the input values or not? Is it up to preference?

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [November 20, 2025, 5:06pm UTC](https://discourse.julialang.org/t/using-step-in-the-range-function/134011/2 "2025-11-20T17:06:48Z")

</div>

Looking at the signatures in the documentation

```julia-repl
help?> range
search: range logrange angle rand randn rangebars LinRange rangebars! cancel ztickrange ytickrange xtickrange

  range(start, stop, length)
  range(start, stop; length, step)
  range(start; length, stop, step)
  range(;start, length, stop, step)
(...)

```

there is no version where `step` is a positional argument, so to directly answer the question: no, this is not possible.

You can use different range-types, though, like a `StepRange` (a.k.a. `start:step:stop`):

```julia-repl
julia> StepRange(1, 1, 5) # start, step, stop
1:1:5

julia> 1:1:5 |> collect
5-element Vector{Int64}:
 1
 2
 3
 4
 5

```

> [@Queenvictoria](#):
>
> Also is it better to define the input values or not? Is it up to preference?

(Assuming by input value you mean the keyword argument (keys)), yeah, I’d say this is a personal preference. If you use the function a lot, you’ll likely get tired of typing out `start = ` every time 🙂
