Hi, I am learning Golang, and I am new to programming, I want to clear my confusion here, Please have a look at the attached screenshot, there is a sub_slice := slice[0:3] (red circled) and the output of its are [20 30 40], Is it right? As per my understanding it should [10 20 30] as 0 is for 10, 1 is for 20, 2 is for 30, and 3 is for 40. Please correct me if I am wrong.
Hi,
it’s a normal behaviour, sub_slice
is not applied on array arr
but on array slice
and slice
array start with 20
.
You can use this link to reproduce the test different scenarion.
https://go.dev/tour/moretypes/7
Regard
Ok, thanks for your reply.
1 Like