On Sat, 2025-09-20 at 12:24 +0200, Jan Mercl wrote:
> On Sat, Sep 20, 2025 at 12:05 PM Dean Schulze
> <[email protected]> wrote:
> 
> > The break keyword terminates execution of a select statement, but
> > is there any real use for break in a select / case statement?
> 
> For example:
> 
> loop:
>         for ... {
>                 switch ... {
>                 case foo:
>                         ...
>                 case bar:
>                         break loop
>                 }
>         }
> 

Also, it means that you can avoid an else block, instead breaking at
the end of the true block of an it statement

select {
case v <- c:
        if trueCase(v) {
                do stuff.
                break
        }
        // false case
        do other stuff.
...
}

-- 
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].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/12cf1f82b34b336c3e70cbab9684ad353a0d4d0b.camel%40kortschak.io.

Reply via email to