Hello! I am a beginner. I have a dictionary (all values are arrays) I want to put the values from the A B C D array [0] into a new array. I did get the result I wanted. But I don't think this is a good way to do it. Because the number of arrays in other dictionaries may be different.
I think I should use a for loop or something to get the result, my attempt failed. Please give me some good advice. Thanks!
extends Node
var dict = {
"A": [1, 2, 3, 4],
"B": [12, 4, 3, 8],
"C": [true, true, false,true],
"D": ["L1","L2", "L3", "L4"],
}
func _ready():
var arr= dict.values() #Puts all the dictionary into an array
var num= max(dict.size(),dict.size()) #There are 4 arrays in dict
#(funny method)
var new_arr = [arr[0][0],arr[1][0],arr[2][0],arr[3][0]]
prints(new_arr)
return new_arr #print:[1, 12, True, L1]-- But.