d13300bed675bb45b753efd4e057e145a7516ab7 — kotrunga 8 months ago 2f386b7
Add 1.3.13 making slices
1 files changed, 29 insertions(+), 0 deletions(-)

A basics/structs-slices-maps/1.3.13_making-slices.go
A basics/structs-slices-maps/1.3.13_making-slices.go => basics/structs-slices-maps/1.3.13_making-slices.go +29 -0
@@ 0,0 1,29 @@
+ /*
+ 	Notes 1.3.13
+ 
+ 	- You can make slices with the built in make() function
+ 	- The make() function allocates a zeroed array and returns a slice that points to it
+ 	- make(type, length, capacity)
+ 	*/
+ 
+ package main
+ 
+ import "fmt"
+ 
+ func main() {
+ 	a := make([]int, 5)
+ 	printSlice("a", a)
+ 
+ 	b := make([]int, 0, 5)
+ 	printSlice("b", b)
+ 
+ 	c := b[:2]
+ 	printSlice("c", c)
+ 
+ 	d := b[2:5]
+ 	printSlice("d", d)
+ }
+ 
+ func printSlice(s string, x []int) {
+ 	fmt.Printf("%s len=%d cap=%d %v\n", s, len(x), cap(x), x)
+ }< 
\ No newline at end of file