On Tue, 14 Aug 2018 05:43:07 -0500
Mark Volkmann <r.mark.volkm...@gmail.com> wrote:

> I’m new to Go and I imagine the idea of adding a ternary operator to Go has
> been discussed many times. Rather than repeat that, can someone point me to
> a discussion about why Go doesn’t add this? 

> I’m struggling to understand why it is desirable to write code like this:
> if temperature > 100 {color = “red”} else {color = “blue”}

Because ternary expression (and some other often mentioned "go lacks")
unwittingly leads to code like this: 

```
$templateParse = sub
{ 
s/([<>\|])([A-Za-z]+)(\d+)(\.+)/defined($2->[$3])?$1eq'|'?$2->[$3]:length($2->[$3])>length($&)?substr($2->[$3],0,length($&)):$1eq'>'?''x(length($&)-length($2->[$3])).$2->[$3]:$2->[$3].''x(length($&)-length($2->[$3])):defined($$2)?$1eq'|'?$$2:length(
$$2)>length($&)?substr($$2,0,length($&)):$1eq'>'?''x(length($&)-length($$2)).$$2:$$2.''x(length($&)-length($$2)):"BadData$1$2$3."/ego;}
```

Yes, this above is a SINGLE perl line instead of some 120+ lines of go's
"text/template" for similar functionality. Young cocky "pro" wrote this just
because he could. His older self longs much for ternaries,  pre/post
increments, do{}while and a few other things but is so happy that young
rookies can't pollute code he is responsible for in ways he himself once
did. ;) 

FYC

> R. Mark Volkmann
> Object Computing, Inc.

-- 
Wojciech S. Czarnecki
 << ^oo^ >> OHIR-RIPE

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