I personally do not find ternary operators to be readable in any form.
For those who are truly desperate for that cosmetic one-line kick, though, 
here's an example you can use (which looks just about as unreadable as any 
ternary operator out there):

// ternary returns 12345 if x is positive (x > 0).
// It returns -1 otherwise.
func ternary(x int) int {
    return map[bool]int{true:12345,false:-1}[x>0]
}



On Thursday, April 25, 2019 at 12:20:35 AM UTC+8, Robert Engels wrote:
>
> Yes, but the FAQ has similar concerns about readability and 
> maintainability as reasons for not having generics, but adds the language 
> “may change”... not sure that is consistent with the views on the tenant 
> operator. 
>
> > On Apr 24, 2019, at 9:52 AM, Ian Lance Taylor <ia...@golang.org 
> <javascript:>> wrote: 
> > 
> > The lack of the ?: operator in Go is a FAQ: 
> > https://golang.org/doc/faq#Does_Go_have_a_ternary_form . 
> > 
> > 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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to