mercredi 12 mai 2021

Can I declare two variables inside of if scope in golang? [duplicate]

I started to learn golang. Now, I have started "if" part.

In golang, I knew that is possible to declare variable on if scope. Like this...

if koreanAge := age + 2; koreanAge < 18 {
    return false
}

At this point, I wondered that is possible to declare two variables in if scope. Like this...

if koreanAge := age + 2, japanAge := age + 1; koreanAge < 18 {
    return false
}

In my country, South Korea, golang is not popular than other language.. And I have bad english skills. I can't find information related to this...

If I try to run compiler, This error is shown.

$ go run main.go
# command-line-arguments
.\main.go:11:36: syntax error: unexpected :=, expecting {

Please, need your help. Thanks for read this.

Aucun commentaire:

Enregistrer un commentaire