package main
import (
"fmt"
)
func main() {
s:= []int{1,2}
fmt.Println(s[0:]) // this is expected
fmt.Println(s[1:]) // this is expected
fmt.Println(s[2:]) // this wondering why i didn't recieve slice bounds out of range error
fmt.Println(s[3:]) // here i recieve the error
}
Can some one explain why s[2:] returns empty slice [] but s[3:] errors out. i thought s[2:] should error out too.