This explanation is awesome! 在 2012年7月12日星期四 UTC+8上午12:42:41,Paul Borman写道: > > This has nothing to do with it being nil. The following always fails: > > s[len(s)] = hello > > The length of a nil slice is 0. > > You can "add" to a nil slice, "add" is spelled "append". > > -Paul > > On Wed, Jul 11, 2012 at 9:30 AM, Francisco Souza <f...@acm.org > <javascript:>> wrote: > >> On Wed, Jul 11, 2012 at 1:26 PM, Martin Schnabel <m...@mb0.org >> <javascript:>> wrote: >> >>> Am 11.07.2012 18:21, schrieb Francisco Souza: >>> > On Wed, Jul 11, 2012 at 1:06 PM, DisposaBoy <dispo...@dby.me >>> <javascript:> >>> > <mailto:dispo...@dby.me <javascript:>>> wrote: >>> > >>> > >>> > >>> > On Wednesday, July 11, 2012 5:02:35 PM UTC+1, Thomas Bushnell, BSG >>> > wrote: >>> > >>> > Yes, but similar language is used for maps, and you cannot add >>> > to a nil map. >>> > >>> > >>> > FWIW, you can't add to a nil slice either >>> > >>> > >>> > Yes, you can: http://play.golang.org/p/LSAqZ1wuMI >>> > >>> no, using append creates a new splice. s[0] = "hello" does not work. >>> >> >> s[0] = "hello" does not add "hello" to the slice, but I got your point. >> >> -- >> -fss > > >
-- 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.