Reusing function variables in a `when` conditional

Isn’t the solution to variable scope to pin the variables?