7455a83b1d73a1802d36aa9576aeda1b0b362904 — Colton Hurst 2 months ago 7678282
Add 1.3.18 and 1.3.19
M basics/structs-slices-maps/1.3.18_exercise-slices.go => basics/structs-slices-maps/1.3.18_exercise-slices.go +35 -1
@@ 1,10 1,44 @@ /*
  	Notes 1.3.18
  
+ 	For this one, copy and run the code on the 'A Tour of Go' website.
+ 	This code will work and run, but you won't "see" the image.
+ 
  	Remember, for a range, two values are returned:
  	  - the index
  	  - a copy of the element at that index
  
  	You can omit something being returned with an underscore '_'. (second example)
  	You can also omit the copy if you only want the index. (first example)
- */> 
\ No newline at end of file
+ */
+ 
+ package main
+ 
+ import "golang.org/x/tour/pic"
+ 
+ func Pic(dx, dy int) [][]uint8 {
+ 
+ 	// make the slice of uint8 slices
+ 	// of length dy
+ 	result := make([][]uint8, dy)
+ 	
+ 	// range through result, and set each 1st dimension
+ 	// value to be a uint8 slice
+ 	for i := range result {
+ 		result[i] = make([]uint8, dx)
+ 	}
+ 	
+ 	// range through each value of result, and set
+ 	// the value based on where we are in the range
+ 	for i := range result {
+ 		for j := range result[i] {
+ 			result[i][j] = uint8(0) + uint8(j)
+ 		}
+ 	}
+ 	
+ 	return result
+ }
+ 
+ func main() {
+ 	pic.Show(Pic)
+ }

A basics/structs-slices-maps/1.3.19_maps.go => basics/structs-slices-maps/1.3.19_maps.go +25 -0
@@ 0,0 1,25 @@
+ /*
+ 	Notes 1.3.19
+ 
+ 	A map "maps" keys to values.
+ 
+ 	The zero value of a map is nil.
+ */
+ 
+ package main
+ 
+ import "fmt"
+ 
+ type Vertex struct {
+ 	Lat, Long float64
+ }
+ 
+ var m map[string]Vertex
+ 
+ func main() {
+ 	m = make(map[string]Vertex)
+ 	m["Bell Labs"] = Vertex {
+ 		40.68433, -74.39967,
+ 	}
+ 	fmt.Println(m["Bell Labs"])
+ }< 
\ No newline at end of file