042d2992a8424c416efdfdbffc68d94e659ae1eb — kotrunga 6 months ago b10fb21
Added 1.3.11 and modified 1.3.4 comment
A basics/structs-slices-maps/1.3.11_slice-len-cap.go => basics/structs-slices-maps/1.3.11_slice-len-cap.go +34 -0
@@ 0,0 1,34 @@
+ /*
+ 	Notes 1.3.11
+ 
+ 	- A slice has a length and a capacity
+ 		- length: number of elements in the slice
+ 		- capacity: number of elements in the underlying array, counting from the
+ 			first element of the slice
+ 	- %v is the value in a default format (used in the printf())
+ */
+ 
+ package main
+ 
+ import "fmt"
+ 
+ func main() {
+ 	s := []int{2, 3, 5, 7, 11, 13}
+ 	printSlices(s)
+ 
+ 	// Slice the slice to give it zero length
+ 	s = s[:0]
+ 	printSlices(s)
+ 
+ 	// Extend its length.
+ 	s = s[:4]
+ 	printSlices(s)
+ 
+ 	// Drop its first two values.
+ 	s = s[2:]
+ 	printSlices(s)
+ }
+ 
+ func printSlices(s []int) {
+ 	fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
+ }< 
\ No newline at end of file

M basics/structs-slices-maps/1.3.4_struct-pointers.go => basics/structs-slices-maps/1.3.4_struct-pointers.go +3 -2
@@ 2,8 2,9 @@ Notes 1.3.4
  
  	- You can make struct pointers
- 	- We could write (*p).X to access the X field in the 'v' Vertex struct
- 	  Shorthand just uses the dot operator, removing the explicit dereference
+ 	- We could write (*p).X to access the X field in the 'v' Vertex struct.
+ 		Shorthand just uses the dot operator, removing the explicit dereference
+ 	- You can obtain these from slice s with len(s) and cap(s)
  */
  
  package main