Storing the LU decomposition of a matrix

This section of the manual might help clear things up: Scope of Variables · The Julia Language

Inside your logpdf! function, Y = lu(x) rebinds Y to a new value lu(X), but only within the function’s local scope. This doesn’t affect the global Y because it’s a different Y that only exists inside your function. Your local Y shadows the Y passed as the argument.

And if you find all this a bit confusing, you’re not alone: