[Feature Request] Overloaded operator for add()

It would be nice if there would be an overloaded operator for the append function on lists.

So instead of writing:
a = listOf(1, 2, 3, 4) a.add(5)

We could write:
a = listOf(1, 2, 3, 4) a[] = 5

I find it much more readable. PHP has this implemented and I really miss it in every other language.

You can’t add to a read-only list, but this will work:

var a = listOf(1, 2, 3, 4)
a += 5 // creates a new list

Or:

val a = mutableListOf(1, 2, 3, 4)
a += 5 // appends to the existing list

Ahh ok thanks :slight_smile: That is even better.
This thread can be deleted therefore by an admin :wink: