Yep, the problem is due largely to gofmt. Ternary operator is easily 
misused and hard to read if it is nested. That's why i prefer if 
expression(without needing to add a new operator and even if it was deep 
nested in the worst case, its complexity would equal a deep nested if 
statement,its readability would no worse than if statement).

在 2018年8月17日星期五 UTC+8上午6:30:41,Matthias B.写道:
>
> On Wed, 15 Aug 2018 07:46:51 -0700 (PDT) 
> Hoo Luu <qq510...@gmail.com <javascript:>> wrote: 
>
> > 在 2018年8月15日星期三 UTC+8上午12:43:37,Mark Volkmann写道: 
> > 
> > > var color = temperature > 100 ? “red” : “blue”     
> > 
> >   
> > Although this feature will not be accepted, we could just talk about 
> > it. I prefer 'if-expression'  to ternary. 
> > 
> > var color = if temperature > 100 { "red" } else { "blue" } 
> > 
> > vs. current if statement syntax: 
> > 
> > var color 
> > if temperature > 100 { 
> >     color = "red" 
> > } else { 
> >     color = "blue" 
> > } 
> > 
>
> I get the impression that the real issue here is that gofmt will break 
>
> if temperature > 100 { color = "red" } else { color = "blue" } 
>
> over multiple lines and that what the people asking for a ternary 
> operator really want is a one-liner. So ask yourselves, if gofmt were 
> to format your ternary operator (or the above suggested if-expression) 
> identical to the if statement, i.e. across the same number of lines, 
> would you still want it? 
>
> var color = 
>     if temperature > 100 { 
>          "red" 
>     } else { 
>          "blue" 
>     } 
>
>
> var color = 
>     temperature > 100 ? 
>           "red" 
>     : 
>           "blue" 
>
>
> If you would NOT use these, your real issue is with gofmt, not the Go 
> language. 
>
>
> MSB 
>
> -- 
> To understand recursion you must first understand recursion. 
>
>

-- 
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