I had read that when using a pure-function it was a good general practice to enclose the function and the associated ampersand in parenthesis.
(#^2 &)[a]
I have found this to work fine and adopted the practice.
Then I found it would not work with this example:
{Animator[Dynamic[x, (x = Round[#, 0.001] &)]], Dynamic[x]}
When you click Run, nothing happens.
For this specific example I have to place the ampersand after the parenthesis in order for it to work.
{Animator[Dynamic[x, (x = Round[#, 0.001]) &]], Dynamic[x]}
I would appreciate it if this behavior could be explained.
Hold[x = # &] // FullForm
andHold[(x = #) &] // FullForm
. You need the whole assignment to be a function when in first example&
binds with rhs faster thanSet
. Looking for duplicate... $\endgroup$