Skip to content

Instantly share code, notes, and snippets.

@Adron
Last active May 20, 2019 01:02
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 Adron/a362eac92b1a63797120f03460ed8669 to your computer and use it in GitHub Desktop.
Save Adron/a362eac92b1a63797120f03460ed8669 to your computer and use it in GitHub Desktop.
Trying Out Composite Types
fmt.Println("Hello, let's talk composite types.")
basketOfStuff := [3]string{"The first string","second","This string."}
var zeeValues [2]int
for i, v := range basketOfStuff {
fmt.Printf("Value %d: %s\n", i, v)
}
fmt.Println(zeeValues)
if zeeValues[0] == zeeValues[1] {
fmt.Println("The values are the same, this doesn't instantiate like the `new` keyword.")
} else {
fmt.Println("The way go appears to instantiate unset variable values, such as in this array is like the `new` keyword instantiation.")
}
zeeValues[0] = 1 + 52 * 3
zeeValues[1] = 9
fmt.Println(zeeValues[len(zeeValues) - 1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment