Last active
May 20, 2019 01:02
-
-
Save Adron/a362eac92b1a63797120f03460ed8669 to your computer and use it in GitHub Desktop.
Trying Out Composite Types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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