# [] operator

Source: https://ref.dm-lang.org/operator/leftsquarerightsquare

This is used to access an element of a list.

```dm
var/L[2]  // declares list of size 2
L[1] = 10 // assign first element
```

If you want to use a datum like a list, you can [overload](https://ref.dm-lang.org/operator/overload.md) the operator by defining an `operator[]` proc for reading a value, and `operator[]=` for writing a value. Those overloads also apply if you use the null-conditional `?[]` operator.

### See also
- [list](https://ref.dm-lang.org/list/index.md)
- [operators](https://ref.dm-lang.org/operator/index.md)
- [?[] operator](https://ref.dm-lang.org/operator/queryleftsquarerightsquare.md)
