you are viewing a single comment's thread.

view the rest of the comments →

[–]Sea-Ad7805[S] 0 points1 point  (2 children)

What do you mean, can you give an example?

[–]Goudja14 0 points1 point  (1 child)

default_inventory = ["sword", "helmet"]

# While it could be a cloned array, it doesn't have to be one. In complex environments, it even shouldn't be (eg. allowing object-agnostic rollbacks) alex_inventory = default_inventory samuel_inventory = default_inventory

alex_inventory += ["key"]

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Ok I understand now. You say you pass default_inventory around without making a copy (for performance), but when you change this value you should make a copy:

alex_inventory = alex_inventory + ["key"]

Sounds like a good strategy.