FAQ
package main

import "fmt"

func main() {
     x, y, z int := 1, 2, 3
     c, python, java := true, false, "no!"

     fmt.Println(x, y, z, c, python, java)
}

Why doesn't the first short initialiser line work, but the second does.
Thank you.

--
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 Aug 20, 2013 at 3:19 am
    A short variable declaration cannot name the type on the LHS.

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

    --
    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.
  • Jesse McNelis at Aug 20, 2013 at 3:34 am

    On 20/08/2013 1:19 PM, wrote:
    package main

    import "fmt"

    func main() {
    x, y, z int := 1, 2, 3
    Perhaps you want.
    var x,y,z int = 1,2,3

    --
    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.
  • Scott Ferguson at Aug 20, 2013 at 1:12 pm
    Or:

    x, y, z := 1, 2, 3

    On Monday, August 19, 2013 11:34:44 PM UTC-4, Jesse McNelis wrote:

    On 20/08/2013 1:19 PM, <rickin...@gmail.com <javascript:>> wrote:

    package main

    import "fmt"

    func main() {
    x, y, z int := 1, 2, 3
    Perhaps you want.
    var x,y,z int = 1,2,3
    --
    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
postedAug 20, '13 at 3:19a
activeAug 20, '13 at 1:12p
posts4
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase