You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
given s := []int{2, 3, 5, 7, 11, 13}, s[1:4] gives [3 5 7]. This is correct. However, s[:4] gives [3 5 7 11] this is clearly incorrect. Here is the complete code:
package main
import "fmt"
func main() {
s := []int{2, 3, 5, 7, 11, 13}
s = s[1:4]
fmt.Println(s)
s = s[:4]
fmt.Println(s)
}
Context: http://127.0.0.1:3999/moretypes/10
given
s := []int{2, 3, 5, 7, 11, 13}
,s[1:4]
gives[3 5 7]
. This is correct. However,s[:4]
gives[3 5 7 11]
this is clearly incorrect. Here is the complete code:and the output:
The same behavior is present at https://tour.golang.org/moretypes/10
The text was updated successfully, but these errors were encountered: