Created
July 2, 2022 10:29
-
-
Save tsuyukimakoto/ad793d9da840693e678454543e418473 to your computer and use it in GitHub Desktop.
scopeを狭くできるif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func a() (x string, y bool) { | |
return "test", true | |
} | |
func main() { | |
if _, y := a(); y { | |
fmt.Println("true: ", y) | |
} else { | |
fmt.Println("false", y) | |
} | |
// fmt.Println("result: ", y) <- out of scope | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment