[ACCEPTED]-Multiple initializers in a Go if statement-go
Accepted answer
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
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
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.