diff --git a/Section10/78.go b/Section10/78.go new file mode 100644 index 0000000..18636a6 --- /dev/null +++ b/Section10/78.go @@ -0,0 +1,34 @@ +package main + +import "fmt" + +func main() { + var cities []string + fmt.Println("cities is equal to nil: ", cities == nil) + fmt.Printf("cities %#v\n", cities) + fmt.Println(len(cities)) + + numbers := []int{21, 13, 54, 95} + fmt.Println(numbers) + + nums := make([]int, 2) + fmt.Printf("%#v\n", nums) + + type names []string + friends := names{"Dan", "Maria"} + fmt.Println(friends) + + myFriend := friends[0] + fmt.Println("My best friend is ", myFriend) + + friends[0] = "Gabi" + fmt.Println("My best friend is ", friends[0]) + + for index, value := range numbers { + fmt.Printf("index: %v, value: %v\n", index, value) + } + + var n []int + n = numbers + fmt.Println(n) +} diff --git a/Section10/79.go b/Section10/79.go new file mode 100644 index 0000000..78ff56f --- /dev/null +++ b/Section10/79.go @@ -0,0 +1,35 @@ +package main + +import "fmt" + +func main() { + var n []int + fmt.Println(n == nil) + + m := []int{} + fmt.Println(m == nil) + + a, b := []int{1, 2, 3}, []int{1, 2, 3} + //fmt.Println(a == b) + + var eq bool = true + + a = nil + + for i, valueA := range a { + if valueA != b[i] { + eq = false + break + } + } + + if len(a) != len(b) { + eq = false + } + + if eq { + fmt.Println("a and b slices are equal") + } else { + fmt.Println("a and b slices are not equal") + } +}