I can't describe exactly the problem I'm experiencing, but this kind of problem has a remarkable feature, that is, commands which couldn't work in the before can be executed correctly when i turn off the Mathematica and reopen it. Later, I know function "Clear[]", it can also solve this kind problem in the most occasions. But sometimes it's not very convenient to use Clear[] for multiple variables. I think this kind problem probably has something to do with the naming of variables and the life cycle and scope, and I want to ask 1. if there are some good habits to avoid such problems, and 2. whether there is a way to solve it other than restart Mathematica.
Asked
Active
Viewed 69 times
2
Clear["Global\*"]will clear all symbols in theGlobal` context – Bob Hanlon Dec 28 '22 at 20:43ClearAllin front of my definitions. So, if I'm definingmyFunc[...]:=..., I'll change it toClearAll[myFunc];myFunc[...]:=.... Then, each time I make a change and re-evaluate that cell, I know I'm starting from a "clean slate". Typically I'll remove these superfluousClearAlls when things have settled. – lericr Dec 28 '22 at 22:25