Closed sammo1235 closed 1 year ago
Good catch fix; thank you! ❤️
This will still share references with nested values like [[1,2,3]]
– perhaps we want to do a deep dup. I'll have a think during our next cooldown in about 4 weeks.
Merged and released. Thanks so much for your contribution and your patience, @sammo1235 :)
I decided that a shallow dup
is enough for now – if anyone wants to PR a deep dup, go for it!
Using @frank-west-iii 's first code example, slightly modified, we can see that the default array value being passed is ultimately the same object used in all instances of the class:
To solve this I simply dupe the value on initialization so each instance gets its own unique object.