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
Post a Comment