I have a extremely simple question on Button. I tried to append values to associations. The Append works good with given value outside button, but once it is inside Button, it doesn't append the value to the association. Here is my code:
key = "hi"
value = {1, 1, 1}
dict = <||>
Button["Update ftdict", Append[dict, key -> value]; Print[dict]]
This button won't work. But following code works:
Append[dict, key -> value]
And give output as following:
<|"hi" -> {1, 1, 1}|>
I don't understand why my code appears to work at top-level but fails when I put it in a button. How can I fix the code to work in a button?
Button["Update ftdict", AppendTo[dict, key -> value]; Print[dict]]orButton["Update ftdict", dict = Append[dict, key -> value]; Print[dict]]? – kglr May 23 '18 at 05:27