If instead of writing: temperature > 80 ? red : green you choose to follow Marcus and write instead: map[bool]string{true:"red",false:"green"}[temperature>80]
OR call func ternary(x int) int { return map[bool]int{true:12345,false:-1}[x>0] } Go right ahead ! ..as they say, "different strokes for different folks" But don't deny others the ability to choose the first alternative On Wednesday, April 24, 2019 at 12:34:09 PM UTC-4, Marcus Low wrote: > > color := map[bool]string{true:"red",false:"green"}[temperature>80] > Here you go. > > On Wednesday, April 24, 2019 at 10:08:53 PM UTC+8, Mark Volkmann wrote: >> >> Are there really developers that find this unreadable? >> >> color := temperature > 80 ? “red” : “green” >> >> I know what you are going to say. People will nest them. But even nested >> usage can be readable when formatted nicely with one condition per line. >> Another alternative is to allow only unnested ternaries. >> >> R. Mark Volkmann >> Object Computing, Inc. >> >> > On Apr 24, 2019, at 8:58 AM, Jan Mercl <0xj...@gmail.com> wrote: >> > >> >> On Wed, Apr 24, 2019 at 3:48 PM L Godioleskky <lgo...@gmail.com> >> wrote: >> >> >> >> The lack of a Go ternary operator is at odds with Go's major theme of >> clean and easy to read syntax. Those who choose not to use the ternary >> operator can always resort back to Go's current 'if -else' or 'case' >> syntax. So Go syntax suffers no negative impact by adding the ternary op to >> its syntax list. Those opposed to the ternary op should not be allowed to >> deny it use other Go programmers, that consider it useful. >> > >> > That's backwards. Those who has to read the code can no more chose not >> > to decrypt the unreadable 4-level nested ternary operations instead of >> > 5 if statements. >> > >> > And to follow on your "logic". If you add to Go even just 10% of what >> > people consider useful, it will become a new C++, only much worse. And >> > again by your very logic. Why we, that haven't chosen to code in C++ >> > in the first place, would be denied by others to use Go, when those >> > others have C++ already at hand? >> > >> > Let everyone use the language he/she likes. Why ruin it for others >> > instead of that by forcing Go to become the same as his/her other >> > favorite language? >> > -- 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.