# Purpose of the Range object

**URL:** <https://discourse.julialang.org/t/purpose-of-the-range-object/5533>\
**Category:** General Usage\
**Created:** [August 24, 2017, 7:18am UTC](https://discourse.julialang.org/t/purpose-of-the-range-object/5533 "2017-08-24T07:18:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sambitdash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sambitdash/32/1377_2.png) [@sambitdash](https://discourse.julialang.org/u/sambitdash)\
**Post date:** [August 24, 2017, 7:18am UTC](https://discourse.julialang.org/t/purpose-of-the-range-object/5533/1 "2017-08-24T07:18:57Z")

</div>

Hi All,

I wanted to return values of `Range` type so that it becomes clear in the end-users mind that we are talking about a number range and will be used as a pages iterator. But, I realize the only way to create a Range is with the function `range`. The `Range` object per-se is not documented and just mapped to `UnionAll`.

Is it the right usage or `Range` object? Or is it intended more from a set theoretic relationship like a domain range ` [1,55.5)` use case. I see various mathematical and statistical operations on it.

I can return a Tuple{Int,Int} or Pair{Int, Int} but both do not provide the same clarity as `Range`.

regards,

Sambit

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 24, 2017, 7:56am UTC](https://discourse.julialang.org/t/purpose-of-the-range-object/5533/2 "2017-08-24T07:56:08Z")

</div>

`Range` is an abstract type, so a value cannot have this type, only a subtype of `Range`.

For integers, `UnitRange` should be fine. You can use the `a:b` constructor. The most commonly understood meaning is _“all integers between `a` and `b`, inclusive”_, but you can use it for anything you like.

For floating point intervals, various packages have different implementations, with different semantics.

---

<div class="post-metadata">

**Author:** ![sambitdash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sambitdash/32/1377_2.png) [@sambitdash](https://discourse.julialang.org/u/sambitdash)\
**Post date:** [August 24, 2017, 8:00am UTC](https://discourse.julialang.org/t/purpose-of-the-range-object/5533/3 "2017-08-24T08:00:58Z")

</div>

Unfortunately, the `Range` object concrete types are not documented clearly. From the REPL help.

```julia
help?> UnitRange
search: UnitRange AbstractUnitRange

  No documentation found.

  Base.UnitRange is of type UnionAll.

     Summary
    ≡≡≡≡≡≡≡≡≡

  struct UnionAll <: Type{T}

     Fields
    ≡≡≡≡≡≡≡≡

  var :: TypeVar
  body :: Any

     Supertype Hierarchy
    ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  UnionAll <: Type{T} <: Any

help?> AbstractUnitRange
search: AbstractUnitRange

  No documentation found.

  Base.AbstractUnitRange is of type UnionAll.

     Summary
    ≡≡≡≡≡≡≡≡≡

  struct UnionAll <: Type{T}

     Fields
    ≡≡≡≡≡≡≡≡

  var :: TypeVar
  body :: Any

     Supertype Hierarchy
    ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  UnionAll <: Type{T} <: Any

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 24, 2017, 8:07am UTC](https://discourse.julialang.org/t/purpose-of-the-range-object/5533/4 "2017-08-24T08:07:57Z")

</div>

I am sure pull requests for documentation would be welcome; however, most of the documentation for `UnitRange` would be found in the manual where `:` is discussed. [These](https://docs.julialang.org/en/latest/search/?q=unitrange) would be a good start.

---

<div class="post-metadata">

**Author:** ![sambitdash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sambitdash/32/1377_2.png) [@sambitdash](https://discourse.julialang.org/u/sambitdash)\
**Post date:** [August 24, 2017, 8:15am UTC](https://discourse.julialang.org/t/purpose-of-the-range-object/5533/5 "2017-08-24T08:15:14Z")

</div>

Thanks @Tamas_Papp

I have created an issue as well. [https://github.com/JuliaLang/julia/issues/23421](https://github.com/JuliaLang/julia/issues/23421)
