In trying to test your code, I ran into a couple of problems. First, you put a semicolon after myBool=nil – I had to remove that. But now I get a more interesting error:
Having sorted that out, I get the same results you do. Evidently, the evaluation in the string is being stored when the string is created, not each time it’s printed.
Do you think there is any way to store strings with code in them in a list in such a way so that the code execution is deferred until the time I use the string?
FWIW, using anonymous functions here doesn’t work either, probably because they are implemented as closures which capture and use the original value of variables:
I tried moving both myBool and the ShuffledList out of GameMainDef, but I put them both in the same object. It didn’t occur to me to try putting them in different objects. Weird … whether it’s a bug or a feature may be a semantic question.
The “myBool = true” statement in showIntro() is setting self.myBool, but its self is different from the ShuffledList’s self, since they are distinct objects.
“myList.myBool = true” will set the property in the list object instead.