StringKeyDictionary update
I'm a bit confused by the semantics of StringKeyDictionary. If I want to update a value at a given key, is that
Insert
?3 Replies
Hi @meta-meta. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, in Normcore’s
StringKeyDictionary
, the Insert
method is used to add a new model at a given key, and it will also update (replace) the value if the key already exists. The documentation states:
A model is considered replaced (as opposed to removed and added) if a new model is added that overwrites an existing model under the same key.So, if you want to update the value at a given key, you should use
Insert
. The operation is transactional, meaning the update will not be reflected until the server confirms it, and it may be rejected if another client has modified the same key before your change reaches the server. You can use the completion handler to know if the update was successful or rejected by the server Reference: StringKeyDictionary.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@115161508442275845> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Yes Insert is correct