> Could you please explain, why primes[6:6] okay, but primes[7:7] not? Here you go: Given this as a slice: [2:3:5:7:11:13]
consider primes[6:6]'s meaning. [2:3:5:7:11:13] [ ] 'return the slice starting after the last element of primes and ending after the last element of primes' Now consider prime[7:7]'s meaning. [2:3:5:7:11:13] [ ] 'return the slice starting after the next position beyond the end of the slice, and ending after the next position beyond the end of the slice'. It fails on the first entry - there is no concept of a next position beyond the end of the slice. Think of it like a queue of students standing in line, and the positions a teacher might reference when telling a new student or students where to stand. "Go stand at the head of the line." primes[0:0] "Go stand in place of the first student and send them back to me." primes[0] "Go stand right after the first student." primes[1:1] "Go stand in place of the last student and send them back to me." primes[5:6] "Go stand at the end of the line." primes[6:6] What does primes[7:7] mean at that point? "Go stand behind the person who would be standing at the end of the line if there was one more person there." Nothing conceptually wrong with that - but not supported. But if you had sent a person to stand at the end of the line already, then it would be fine. -- 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. For more options, visit https://groups.google.com/d/optout.