Referencing local variable before assignment results in unexpected behavior

I find this kind of behavior is really helpful to work with optimization packages when I had a really complicate object to be optimized. I just pass that object to other’s optimizers using an anonymous function (with many extra arguments in the original objective function) and get my optimized version object back.

1 Like