Get size row or column in array2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By estebanmolca
:warning: Old Version Published before Godot 3 was released.

Hi, I need get size the array into another array(2d array)…Something like get_size_row
For example:

for i in range (myArray_get_size_row):
     for j in range(myArray_get_size_column):
         myArray[i][j]=rand_range(0,1)

Thank you

:bust_in_silhouette: Reply From: dodgyville

In gdscript I would do:

for i in range(myArray.size()):
    for j in range(myArray[i].size()):
        myArray[i][j] = rand_range(0, 1)

The only disadvantage is that you have to use a loop for, but it works … I have to get used to using the arrays inside the arrays without thinking about arrays2D …
Sorry for my english and thank you very much for answering.

estebanmolca | 2018-01-12 03:39

:bust_in_silhouette: Reply From: Matthew Schultz

Here’s a way I did it without looping

var max_element = array_to_check.max()
var last_element = array_to_check.back()
var cols = max_element.x if max_element.x > last_element.x else last_element.x
var rows = max_element.y if max_element.y > last_element.y else last_element.y