---
title: "TextRange"
description: "An immutable text range class, represents a text range from [start] (inclusive) to [end]
(exclusive). [end] can be smaller than [start] and in those cases [min] and [max] can be used in
order to fetch the values."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
value class TextRange internal constructor(private val packedValue: Long)
```


An immutable text range class, represents a text range from `start` (inclusive) to `end`
(exclusive). `end` can be smaller than `start` and in those cases `min` and `max` can be used in
order to fetch the values.


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val start: Int
```


<div class='sourceset sourceset-common'>Common</div>


```kotlin
val end: Int
```


<div class='sourceset sourceset-common'>Common</div>


```kotlin
val min: Int
```


The minimum offset of the range.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val max: Int
```


The maximum offset of the range.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val collapsed: Boolean
```


Returns true if the range is collapsed



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val reversed: Boolean
```


Returns true if the start offset is larger than the end offset.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val length: Int
```


Returns the length of the range.



## Functions

```kotlin
fun intersects(other: TextRange): Boolean
```


Returns true if the given range has intersection with this range


```kotlin
operator fun contains(other: TextRange): Boolean
```


Returns true if this range covers including equals with the given range.


```kotlin
operator fun contains(offset: Int): Boolean
```


Returns true if the given offset is a part of this range.


## Companion Object

#### Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
val Zero = TextRange(0)
```




