Adding items to key list-value in dictionary (without set value for key in dictionary)

Hello,
I try this and it works.
I added an item to a list which is the value of a key... it works.
I did it without calling set value for key in dictionary.

Please, can someone (tag removed by mod) kindly confirm if this is correct or if it worked by chance?
That is, does the dictionary get modified by modifying a list returned by get value for key in dictionary?

DictionaryTest.aia (2.6 KB)


Best regards,
Osmany

there is no need to @ somebody in first post.

and

it's correct, since List is working like this.

for better understand this, you can search by value and by ref.

All you are doing is adding an item to a list that already exists. Nothing new or chancy about it. If you work through your blocks step by step, you will see.

AI2 lists are linked Lists, so this is expected behavior.
For proof, search this board for Ouroborous.

1 Like

Thanks @ABG ,

Yes, it looks like both SELECT LIST ITEM and GET VALUE FOR KEY IN DICTIONARY return references to the requested value, doesn't a copy of the value. I didn´t find where that is said.

I also tried with LIST,



Best regards,
Osmany

Hi there,

Here I leave a counterexample, with which adding an element to the list does have the same effect.
The property LISTVIEW.ELEMENTS seems to return a copy of its value, so modifying it does not modify the ListView.

Therefore it is necessary to call SET LISTVIEW.ELEMENTS

Best regards,
Osmany

Yes, this is also well known. if you add an element, you need to call list elements again.

You should really add a new item to the underlying list, then set the list elements with that list.