You don't need to return an immutable copy. The return value is declared as immutable, so the fact that it's mutable is an implementation detail. Additionally, the matches aren't stored internally, so it doesn't really matter if the array is messed with.