Method

# Operator_Redim

<div class="rst-class">

forsearch

</div>

Operator

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

The `Redim</api/language/redim>` statement can be overloaded by a class. To use it, implement <span class="title-ref">Operator_Redim</span> in your class.It makes the `Redim</api/language/redim>` statement available for objects that were not declared as arrays.

<div class="important">

<div class="title">

Important

</div>

This is not currently supported for Android.

</div>

## Sample code

``` xojo
Class OneBasedArray
  Sub Constructor(bounds As Integer = 0)
    Redim mArray(bounds - 1)
  End Sub

  Function Count() As Integer
    Return mArray.LastIndex + 1
  End Function

  Sub Operator_Redim(newSize As Integer)
    Redim mArray(newSize - 1)
  End Sub

  Function Operator_Subscript(index As Integer) As Variant
    Return mArray(index - 1)
  End Function

  Sub Operator_Subscript(index As Integer, Assigns v As Variant)
    mArray(index - 1) = v
  End Sub

  Private mArray() As Variant
End Class
```

## Compatibility

|                       |                               |
|-----------------------|-------------------------------|
| **Project Types**     | Console, Desktop, Mobile, Web |
| **Operating Systems** | iOS, Linux, macOS, Windows    |

<div class="seealso">

`Operator Overloading</api/language/operators/operator_overloads/operator_overloading>`, `Operator Subscript</api/language/operators/operator_overloads/operator_subscript>`, `Redim</api/language/redim>` statements.

</div>
