FAQ
Hi all,

Just curious, why the following statements make a compile error: "cannot
assign to slice[2:]"?

         slice := []int{1, 2}
slice[2:] = append(slice[2:], 3)

slice[2:] is also a slice, and it conforms to the definition of append:

         func append(slice []Type, elems ...Type) []Type

Thanks in advance!

Best Regards
Nan Xiao

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 8 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 21, '16 at 1:08a
activeMar 24, '16 at 3:09p
posts8
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase