Re: [go-nuts] "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-05 Thread judsonwilson via golang-nuts
> > > Maybe `fallthrough` statement cannot be used in `if` block even if it's > put inside `swicth` block) > > True: It may be used only as the final non-empty statement in such a > clause . > > why to make this restriction? One reason is

Re: [go-nuts] "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-04 Thread T L
On Friday, August 4, 2017 at 6:59:41 PM UTC-4, Doğan Kurt wrote: > > Fallthrough must be a design choice but goto's restriction is a necessity. > > What happens if you jump into the middle of an if block? You skipped the > condition check, you run the code after the goto label, what about the

Re: [go-nuts] "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-04 Thread Doğan Kurt
Fallthrough must be a design choice but goto's restriction is a necessity. What happens if you jump into the middle of an if block? You skipped the condition check, you run the code after the goto label, what about the code before the label, there might be some variables initialized, and how

Re: [go-nuts] "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-04 Thread T L
On Tuesday, August 1, 2017 at 8:41:21 AM UTC-4, Jan Mercl wrote: > > On Tue, Aug 1, 2017 at 2:34 PM Fumi Takeuchi > wrote: > > > Example code: https://play.golang.org/p/dVtPVt3oKt > > > > Maybe `fallthrough` statement cannot be used in `if` block even if it's > put

Re: [go-nuts] "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-01 Thread Jan Mercl
On Tue, Aug 1, 2017 at 2:34 PM Fumi Takeuchi wrote: > Example code: https://play.golang.org/p/dVtPVt3oKt > > Maybe `fallthrough` statement cannot be used in `if` block even if it's put inside `swicth` block) True: It may be used only as the final non-empty statement in

[go-nuts] "fallthrough statement out of place" in `if` block inside `swicth` block

2017-08-01 Thread Fumi Takeuchi
Example code: https://play.golang.org/p/dVtPVt3oKt --- I thought this code will work fine, but didn't, because of "fallthrough statement out of place" error. Maybe `fallthrough` statement cannot be used in `if` block even if it's put inside `swicth` block) So, my question is, which is better