On Thu, 7 Sep 2017 05:00:18 -0700 (PDT)
[email protected] wrote:
> lhow about this, and it is a construct which can be used not only for
> errors:
> watch err != nil {
> yo1, err = do_stuff1()
> yo2, err = do_stuff2()
> yo3, err = do_stuff3()
> } then {
> // handle your error
> }
Without language change
watch:
for i := 0; err == nil; i++ {
switch i {
case 0:
err, yo1 = doSomething(i)
case 1:
err, yo2 = doSomething(i)
case 2:
err, yo3 = doSomething(i)
default:
break watch
}
}
if err != nil {
// on error do something
}
https://play.golang.org/p/s6xh1qM4sx
> This statement could be used for other cases as well, it is easy to read
> and understand, and it saves the programmer from line duplication.
Above at least gives to the reader visual breaks (with 'case' lines ;)
> Martin
>
--
Wojciech S. Czarnecki
<< ^oo^ >> OHIR-RIPE
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.