On Saturday, 8 October 2016 16:34:33 UTC+3, xiio...@gmail.com wrote: > > If you can stomach GOTO the code : > > i := a > > loop1: //stuff > > //..fmt.Println(i, a, b) > > //stuff > > if i != b { > > i = i + b - a > > goto loop1 > > } > > > should compile to something fairly sane without the extra variables and > 'ifs' > > ..but it lacks local scope, and the indentation isn't helpful. It's not > good to read when there are multiple loops like a 3d array case. >
In this code you could use empty blocks, e.g.: { i := 0 loop: fmt.Println(i) if i < 10 { i++ goto loop } } or: i := 0 { loop: fmt.Println(i) if i < 10 { i++ goto loop } } or: i := 0 loop: { fmt.Println(i) if i < 10 { i++ goto loop } } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.