Am I going to run into issues if I set the value of a variable directly?

What I mean is, is there any harm in me using something like
Code:
$gameVariables.value(1) = 10
instead of
Code:
$gameVariables.setValue(1, 10)
?

My variable is actually an array, and I only want to change one part of it. Say, my array is [1, 2, 3] and I want to change the 1 to a 5. I can use
Code:
$gameVariables.value(1)[0] = 5
which seems to work fine, but I was wondering if bypassing setValue could cause issues.

I suppose I could do something like
Code:
$gameVariables.setValue(1, [5, ...$gameVariables.value(1).slice(1)])
is setValue is required...
I mean the harm is that you can't do it in the first example because value() is returning a number, and you can't set a number to a different number.

The reason you can do it the second way is that value is returning an array, which you can then index. That won't cause any problems as it's just as if you'd typed the array instead of the variable reference, and you can then do anything with that you could normally do with an array.
If the variable contains an array or an object, then that is a valid reason to do what you are doing. However, to answer your question in a more general sense: unless you have a valid reason for doing so, it is ill-advised to bypass the setValue function.
Thanks, that makes sense.

Original thread: https://forums.rpgmakerweb.com/threads/am-i-going-to-run-into-issues-if-i-set-the-value-of-a-variable-directly.154311/