> For the complete documentation index, see [llms.txt](https://katxupa.gitbook.io/katxupa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://katxupa.gitbook.io/katxupa/get-a-taste-of-katxupa/usage/range.md).

# Range

The `Range` class provides utility methods for working with numeric ranges.

{% content-ref url="/pages/8thS2fvOKTbCkfxuFulL" %}
[Range](/katxupa/get-a-taste-of-katxupa/dip-dive/range.md)
{% endcontent-ref %}

<pre class="language-typescript" data-full-width="false"><code class="lang-typescript">// Example 1: range with step
rangeTo(0,10,3)
    .forEach(it => console.log(`Index: ${it}`));
// Output:
//    Index: 0
<strong>//    Index: 3
</strong>//    Index: 6
//    Index: 9
</code></pre>

```typescript
// Example 2: Creating a Numeric Range
const numericRange = Range.rangeTo(1, 5, 2);
console.log(numericRange); 
// Output: [1, 3, 5]
```

```ts
// Example 3: Creating a Numeric Range (Exclusive)
const numericRangeAlias = rangeUntil(1, 5, 2);
console.log(numericRangeAlias); 
// Output: [1, 3, 5]
```

```ts
// Example 4: Checking if a Value is in Range
const isInRange = Range.inRange(3, 1, 5);
console.log(isInRange); 
// Output: true
```

```ts
// Example 5: Range with chaining Operations 
rangeTo(1, 5, 2)
    .runIt(function () {
        console.log(`multiplying the following range of numbers: ${this}`);
        this.map(it => it * 2)
            .forEach(it => console.log(it));
    });
// Output:
//    multiplying the following range of numbers: 1,3,5
//    2
//    6
//    10

```
