go - Get dimensions of 2d slice -


lets have 4 5 2d array

array := [][]byte{     {1, 0, 1, 0, 0},     {1, 0, 1, 1, 1},     {1, 1, 1, 1, 1},     {1, 0, 0, 1, 0}, } 

how columns , widths of array? want nested loop on array array passed in function may vary in dimensions.

just len of array , len of element of array.

len(array) // 4 len(array[0]) // 5 

as note, using 2d slice, not array. read more go slices here.


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -