Hello!
I am running into this issue. Given a dictionary that has an array as one of the items, I am not finding the way to append a value to the array inside the ditionary. I might be missing something. Is this possible?
Thanks!
Append value to a dictionary's array item for a key? (VEX)
2838 4 0-
- Cicuta
- Member
- 103 posts
- Joined: Nov. 2019
- Offline
-
- tamte
- Member
- 9380 posts
- Joined: July 2007
- Offline
it is definitely possible, but rather than us guessing whether you are dealing with Python or dictionaries in VEX or dictionary attributes and giving you random examples, it's better if you clarify your exact issue you are running into
but in short in VEX:
in Python:
but in short in VEX:
//if myDict contains: {"key": [1, 2]} append(myDict["key"], 3); //results in: {"key": [1, 2, 3]}
in Python:
#if myDict contains: {"key": [1, 2]} myDict["key"].append(3) #results in: {"key": [1, 2, 3]}
Edited by tamte - Dec. 31, 2023 15:42:40
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- Cicuta
- Member
- 103 posts
- Joined: Nov. 2019
- Offline
-
- Cicuta
- Member
- 103 posts
- Joined: Nov. 2019
- Offline
Hello again!
While this is indeed working for integers and floats, it is not working if the array for that key is a string array. It is giving me the following error:
Invalid source /obj/hashmaps_dictionaries/anagram_list_hashmaps/attribvop1.
(Error: Ambiguous call to function append(). Candidates are: void append(string &; string), void append(string &; string) (56,1:6)).
Is there a workaround or something that I am missing?
(It also seems like vector arrays aren't supported either, upon testing I am having the same issue reported here: https://www.sidefx.com/forum/topic/81985/)
Thanks!
tamte
but in short in VEX://if myDict contains: {"key": [1, 2]} append(myDict["key"], 3); //results in: {"key": [1, 2, 3]}
While this is indeed working for integers and floats, it is not working if the array for that key is a string array. It is giving me the following error:
Invalid source /obj/hashmaps_dictionaries/anagram_list_hashmaps/attribvop1.
(Error: Ambiguous call to function append(). Candidates are: void append(string &; string), void append(string &; string) (56,1:6)).
Is there a workaround or something that I am missing?
(It also seems like vector arrays aren't supported either, upon testing I am having the same issue reported here: https://www.sidefx.com/forum/topic/81985/)
Thanks!
Edited by Cicuta - Dec. 31, 2023 20:30:56
-
- tamte
- Member
- 9380 posts
- Joined: July 2007
- Offline
Cicutawhile append() seems to have this issue push seems to work so you can potentially use that:
if the array for that key is a string array. It is giving me the following error:
//given myDict contains: {"key": ["1", "2"]} push(myDict["key"], "3"); //results in: {"key": ["1", "2", "3"]}
Cicutathe docs don't list vector arrays in the list of supported dictionary values so it's likely they may not be supported
(It also seems like vector arrays aren't supported either, upon testing I am having the same issue reported here:
you can potentially use serialize() unserialize() functions to convert between flat float array and vector or matrix arrays, therefore store them as flat float array in dictionaries
Edited by tamte - Dec. 31, 2023 22:52:07
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- Quick Links

