You’re also encountering a common gotcha here. The contract with the add method is that it returns a collection with the value added - it may mutate the underlying collection or return a new collection. Always you need to do a = a.add(1) unless you KNOW you are working with a collection that always mutates itself - List mutates so capturing the return value isn’t strictly necessary, but Array has a fixed size so often adding a new value requires that a new array be allocated and returned.
I think @maciej intentionally uses List to avoid the ugly and annoying a[0] = a[0].add(...) idiom. But it’s always worth pointing out because it is indeed a common gotcha!