Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Marcus Low
at is simple really is > simpler. > > var datalen int32 > if value == nil { >datalen = removedKeyken > } else { >datalen = len(value) > } > > > > On Apr 24, 2019, at 11:31 AM, Marcus Low wrote: > > I personally do not find ternary operators to

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Marcus Low
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

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-24 Thread Marcus Low
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

[go-nuts] Re: This Makes No Sense

2019-01-22 Thread Marcus Low
I meant "constant *space* overhead", sorry. On Tuesday, January 22, 2019 at 11:38:02 PM UTC+8, Marcus Low wrote: > > As Justin Israel said, you can probably scan them to int and test them as > ints. > > However, if you *really* need them to be parsed as string, this

[go-nuts] Re: This Makes No Sense

2019-01-22 Thread Marcus Low
As Justin Israel said, you can probably scan them to int and test them as ints. However, if you *really* need them to be parsed as string, this will help your runtime, at the cost of constant overhead: var ( valueSet = map[string]struct{}{ "1":nil, "2":nil, "3":nil,