Why did I use `local`?

Hello,

I’m trying to refresh an old code of mine, about 5 years old. I found this function:

## sort array M with respect to colon j
function sortbycol(M,j)
  local col, perm
  col = M[:,j]
  perm = sortperm(col)[2]
  return(M[perm,:])
end

I don’t remember why I used local. Is it a good practice? Or is it useless? Or what?

It seems to be about hard vs soft scope see here, about changing then back:

Disambiguate by using locals to suppress this warning

3 Likes

Likely useless.

4 Likes