Re: [go-nuts] Accessing elements outside slice using [:]

2025-01-26 Thread Pyrode
Got it 👍 Thanks for the response! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https:

[go-nuts] Accessing elements outside slice using [:]

2025-01-25 Thread Pyrode
Hey, The following code allows elements outside the length of the slice to be accessed. Is this the expected behaviour or a bug? Thanks ``` package main import "fmt" func main() { foo([]int{1, 2, 3, 4}[0:1]) } func foo(bar []int) { fmt.Println(len(bar)) //