0
How to make a 2d slice with dynamic sizing?
Here, I created a 2d slice with a size of var m. This code gives a ERROR How to solve it? https://code.sololearn.com/cSEedWB60P0B/?ref=app
2 odpowiedzi
+ 3
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ You need to also initialize each slice of the 2d-slice:
slice2d := make([][]int,m)
for i:=0;i<m;i++{
slice2d[i] = make([]int,m)
}
+ 1
Giorgos D
It really works! Thank you.