Today I Learned

hashrocket A Hashrocket project

Get the first n items from a slice

Slices can take low and high bounds to determine which items to take.

mySlice[low bound : high bound]
package main

import "fmt"

func main() {
	numbers := []int{1,2,3,4,5,6,7,8}

	var s []int = numbers[0:3]
	fmt.Println(s)
}

=> [1 2 3]
See More #go TILs