Skip to content

Instantly share code, notes, and snippets.

@victorsteven
Created June 24, 2019 10:06
Show Gist options
  • Select an option

  • Save victorsteven/1f57608ff63de166e8a5e9b6c3f76200 to your computer and use it in GitHub Desktop.

Select an option

Save victorsteven/1f57608ff63de166e8a5e9b6c3f76200 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func main() {
//Function scope slice:
//EXAMPLE 1:
integerSlice := []int{10, 20, 30, 40, 50}
stringSlice := []string{"first", "second", "third", "fourth"}
fmt.Println("This is the integer slice: ", integerSlice)
fmt.Println("This is the string slice: ", stringSlice)
// EXAMPLE 2:
// We can also define slice using the "make" builtin function
s := make([]int, 4)
s[0] = 10
s[1] = 20
s[2] = 30
s[3] = 40
fmt.Println("Slice created with 'make': ", s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment