Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ruina11011 |
var arr : Array = [0, 0]
var dic : Dictionary = {}
after declaring the variable, use the for-loop
{0 : [0, 0], 1 : [0, 0], 2 : [0, 0], 3 : [0, 0], 4 : [0, 0], 5 : [0, 0]}
want to make a dictionary of the same type and access the array inside it.
But
for i in range :
dic[i] = arr
When declared in the form above
{0:[0, 0], 2:[…], 3:[…], 4:[…]}
{0:[0, 0], 1:[…], 10:[…], 2:[…], 3:[…], 4:[…], 5:[…], 6:[…], 7:[…], 8:[…], 9:[…]}
{0:[0, 0], 1:[…]}
{0:[0, 0], 1:[…], 10:[…], 11:[…], 12:[…], 13:[…], 2:[…], 3:[…], 4:[…], 5:[…], 6:[…], 7:[…], 8:[…], 9:[…]}
The value is stored only in the key value ‘0’.
How can I put the value of the array [0, 0] into the whole dictionary?
I know it’s possible with dic[i].i to access the dictionary in the dictionary.
But how can I access the array in the dictionary?