On Apr 24, 2019, at 8:04 AM, Mark Volkmann <r.mark.volkm...@gmail.com> wrote:
> 
> 
>> On Apr 24, 2019, at 6:22 AM, Robert Engels <reng...@ix.netcom.com> wrote:
>> 
>> Though to the ops point, not sure why Go doesn’t have the ternary operator - 
>> which is pretty ubiquitous. 
> 
> The idea of adding the ternary operator to Go has been debated many times. 
> It’s clear that those in charge have a strong dislike for it. For me the lack 
> of the ternary operator is one of main things I dislike about Go. It’s nails 
> on a chalkboard for me to write a five line “if” statement when it could have 
> been a one line assignment statement.

I enthusiastically concur with this.  I understand the antagonism toward the 
ternary statement to a point, but there are some things that it just makes 
about a million times easier without sacrificing readability:



fmt.Printf("This parrot is %s.\n", is_dead ? "pining for the fjords" : "alive")



This isn't just a toy example.  Nothing (to my mind) is unclear about this 
statement.

I run into this sort of thing every day; the main thing the ternary statement 
relieves me of is either writing convoluted if/switch/map statements when a 
single line would do, or repeating myself. I'd have to do one or the other to 
resolve the above one-liner, and it wouldn't enhance readability in the 
slightest.


- Dave

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