Correct. For "good style", however, you shouldn't even set the variable values there.
I think that is a special case, where a variable is used as if it were a constant (but dependent on...) and so I would say that way can be acceptable... as exception.