Setter a value on a Collection index

If i want to expose a class parameter whose getter is a mutable List how can I do:

    var getList = alist
      set(value, index) { alist[index] = value }

This is pretty dumbed down. the point is NOT to expose a List and to Find out if there is a way to do Setter on a Collection. Is this possible ? If so how? Operator overloading? Any better method?

You can’t create a setter/getter with an index for a normal property. So the only solution would be using a function instead. However if you only have one collection you want to access you can use something like this

class Bar {
    operator fun get(index: Int): Foo = alist[index]
    operator fun set(index: Int, value: Foo) {
        alist[index] = value
    }
}

val bar = Bar()
val g = bar[5]
bar[42] = Foo()