package main
import "fmt"
func main() {
is := []int{1, 2}
fmt.Println(is[2:]) // no panic here - this includes is[2] which is out of bound still no panic
fmt.Println(is[3:]) // but panic here
fmt.Println(is[2]) // panic here which is acceptable
}
In above mentioned program, there is no panic for is[2:] even though we are accessing element from is[2] to on wards and the slice is having only 2 elements. Why is it so?