On Sun, Jun 21, 2020 at 2:11 PM Laevus Dexter <dkfl10...@gmail.com> wrote: >> >> A receive expression used in an assignment or initialization of the special >> form >> >> x, ok = <-ch >> x, ok := <-ch >> var x, ok = <-ch >> var x, ok T = <-ch >> >> yields an additional untyped boolean result reporting whether the >> communication succeeded. The value of ok is true if the value received was >> delivered by a successful send operation to the channel, or false if it is a >> zero value generated because the channel is closed and empty. > > > Why it's untyped? And how to make the last expression to work? Seems I can't > use anything but bool.
It's untyped mainly because there is no reason to make it typed. You can use a different type by writing code like (untested): type MyBool bool func F(c chan int) { var ( x int ok MyBool ) x, ok = <-c } Ian -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVhm0ZC-Q4joeFAh%2BM7JMUzS9iWaPZEdAmLtasUqpaWvw%40mail.gmail.com.