Created
June 24, 2019 09:19
-
-
Save victorsteven/da05999cd899de6ba120a04fff6fa45e to your computer and use it in GitHub Desktop.
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
| package main | |
| import "fmt" | |
| //Package scope array definition | |
| var integerSlice []int | |
| var stringSlice []string | |
| func main() { | |
| integerSlice = []int{10, 20, 30, 40} | |
| fmt.Println("This is the integer Slice: ", integerSlice) | |
| stringSlice = []string{"first", "second", "third"} | |
| fmt.Println("This is the string slice: ", stringSlice) | |
| printInteger() | |
| } | |
| //This function can access the integerSlice because integerSlice is package scoped | |
| func printInteger() { | |
| fmt.Println("Print the integers: ", integerSlice) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment