FAQ
Hi all,

http://play.golang.org/p/FDcUvHGxuL

why `[]int{0}[0]++` and `[1]int{0}[0]++` are different?

--
chaishushan
http://my.oschina.net/chai2010
https://bitbucket.org/chai2010

--
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/groups/opt_out.

Search Discussions

  • David Symonds at Jun 28, 2013 at 3:36 am
    An array is not a slice.

    http://golang.org/ref/spec#Array_types

    --
    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/groups/opt_out.
  • Daniel Morsing at Jun 28, 2013 at 10:03 am

    On Fri, Jun 28, 2013 at 5:36 AM, David Symonds wrote:
    An array is not a slice.

    http://golang.org/ref/spec#Array_types
    I don't think that is the point. Indexing an array or slice normally
    gives an lvalue, but indexing an array literal gives an rvalue.

    Can't find anything in the spec that suggests this behavior.

    --
    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/groups/opt_out.
  • David Symonds at Jun 30, 2013 at 7:01 am
    A slice literal necessarily presupposes an underlying array, which is
    addressable via the slice index. An array literal has no such
    addressability any more than "7" is an addressable int.

    --
    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/groups/opt_out.
  • Peter Caven at Jun 30, 2013 at 6:34 am
    Hmm .. I'm a bit confused too.
    But rewriting it like this seems to be ok:
      http://play.golang.org/p/3yjtFobvdQ


    On Thursday, June 27, 2013 11:33:34 PM UTC-4, chai2010 wrote:

    Hi all,

    http://play.golang.org/p/FDcUvHGxuL

    why `[]int{0}[0]++` and `[1]int{0}[0]++` are different?

    --
    chaishushan
    http://my.oschina.net/chai2010
    https://bitbucket.org/chai2010
    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 28, '13 at 3:33a
activeJun 30, '13 at 7:01a
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase