Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Created January 26, 2019 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjgiridhar/a83fc0b891d23fa1ee723d6306fbb015 to your computer and use it in GitHub Desktop.
Save cjgiridhar/a83fc0b891d23fa1ee723d6306fbb015 to your computer and use it in GitHub Desktop.
Comparing arrays in Golang
package main
import (
"fmt"
)
func main() {
/* Shorthand declaration */
scores := [4]int{80, 85, 45, 55}
herScores := [...]int{80, 85, 45, 55}
hisScores := [4]int{80, 45, 22, 33}
fmt.Println(scores == herScores) /* Returns truee */
fmt.Println(scores == hisScores) /* Returns false */
fmt.Println(herScores == hisScores) /* Returns false */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment