[ACCEPTED]-Multiple initializers in a Go if statement-go

Accepted answer
Score: 22

Here's how to do it:

package main

import (
    "fmt"
)

func main() {
    if x, y := 5, 38; x == 5 {
        fmt.Printf("Whee! %d\n", y)
    }
}


Tested with this revision:

changeset:   3975:b51fd2d6c160
tag:         tip
user:        Kevin Ballard <xxxxxxxxxxxxxxxxxxxxx>
date:        Tue Nov 10 20:05:24 2009 -0800
summary:     Implement new emacs command M-x gofmt

0

Score: 0
package main
import("fmt")
func main() {
    if x, y := 5, 38; x == 5 {
        fmt.Printf("y = %d\n", y)
        fmt.Printf("x = %d\n", x)
    }
}

https://play.golang.org/p/Sbv6hUmKyA

0

More Related questions