How do I modify an array that is a parameter to a function?

Now I have more question.
In fact, IsValid may not only be used to judge, so can I write it like this?