Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
460 B

  1. package main
  2. import "fmt"
  3. func compArrays() (bool, bool, bool) {
  4. var arr1 [5]int
  5. arr2 := [5]int{0}
  6. arr3 := [...]int{0, 0, 0, 0, 0}
  7. arr4 := [5]int{0, 0, 0, 0, 9}
  8. return arr1 == arr2, arr1 == arr3, arr1 == arr4
  9. }
  10. func main() {
  11. comp1, comp2, comp3 := compArrays()
  12. fmt.Println("[5]int == [5]int{0} :", comp1)
  13. fmt.Println("[5]int == [...]int{0, 0, 0, 0, 0}:", comp2)
  14. fmt.Println("[5]int == [5]int{0, 0, 0, 0, 9} :", comp3)
  15. }