unexpected semicolon or newline before else even though there is neither before else if

后端 未结 2 1606
不知归路
不知归路 2021-01-17 18:34

I\'m trying to fix these errors in my golang code and if someone could help me with that, I\'d appreciate it.

Here is my code: http://play.golang.org/p/yELWfIdWz5

2条回答
  •  一生所求
    2021-01-17 18:47

    https://golang.org/doc/effective_go.html#if

    You can find the explanation here, but I find it to be a bit bikeshedding. For example, this, unintuitive as it is, compiles:

        if your_age >= 16 {
        say("\n You can earn a Drivers License."); } else
        if your_age >= 18 { say("\n You can vote."); } else
        { say("\n You can have fun."); }
    

提交回复
热议问题