I’m trying to implement a simple map to hold instances in verse. But I got a subject error, and can’t figure out how to fix it. May somebody explain what is wrong in my code?
This error is because you are trying to change a variable that has been declared as a constant. Add “var” in front of Components when you initialize it.
It works, thank you! However, it seems a little strange to me. In this case, I didn’t create a new map, I just changed it. In TypeScript, for example, the logic is different for this case.
In Verse maps are immutable. In order to update them you need to mark them as var, then set the map using the set syntax. What is actually happening in this code (set Components[Component.Type] = Component) is that a new map is being created under the hood with Component.Type => Component added/modified from the original map.
Aha, thank you for the explanation; one thing has become clear, with a million more to go!
P.S. You guys should train ChatGPT on your datasets to teach it these kind verses tricks; it would make things easier for all of us