Исходники и презентации
This commit is contained in:
13
lessons/slices_and_arrays/resize_slice/main.go
Normal file
13
lessons/slices_and_arrays/resize_slice/main.go
Normal file
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
data := make([]int, 3, 6) // len = 3, cap = 6
|
||||
|
||||
// fmt.Println(data[4]) // panic
|
||||
|
||||
data = data[:6] // len = 6, cap = 6
|
||||
|
||||
fmt.Println(data[4])
|
||||
}
|
||||
Reference in New Issue
Block a user