[go-nuts] Re: why slice[len:len] okay, but slice[len] fail?

2019-03-08 Thread jake6502
The other answers to your original question are reasonable, and probably helpful. But I would also like to point out the definitive, though maybe less helpful answer to both your original question, and this new one. You see that behavior because the language specification says you should. Read

Re: [go-nuts] Re: why slice[len:len] okay, but slice[len] fail?

2019-03-07 Thread fgergo
Similar reason. You might want to read about slices and arrays in go: https://golang.org/doc/effective_go.html#slices This might be helpful as well: https://gobyexample.com/slices On 3/8/19, Halbert.Collier Liu wrote: > Yes, i see, > thank you so much! > > Could you please explain, why

[go-nuts] Re: why slice[len:len] okay, but slice[len] fail?

2019-03-07 Thread Halbert.Collier Liu
Yes, i see, thank you so much! Could you please explain, why primes[6:6] okay, but primes[7:7] not? *:-)* 在 2019年3月7日星期四 UTC+8下午11:55:40,Robert Johnstone写道: > > Hello, > > When you use the colon, you taking a subset of the data. Further, the > notation is a closed/open. So a slice

[go-nuts] Re: why slice[len:len] okay, but slice[len] fail?

2019-03-07 Thread Robert Johnstone
Hello, When you use the colon, you taking a subset of the data. Further, the notation is a closed/open. So a slice primes[6:6] is all of the element in the array with index >= 6 and index < 6, which is an empty set. Note that the type of the expression primes[6:6] is []int. When you don't