a = flag ? b : c
is much more readable and concise than if flag {
a = b
} else {
a = c
}
battling habits by making useful code inconvenient is just sad a = flag ? b : c
is much more readable and concise than if flag {
a = b
} else {
a = c
}
battling habits by making useful code inconvenient is just sadSure it can be abused and nested beyond human comprehension... just like if-else! So that's a non-argument.
If you're the one trying to figure out what went wrong in production, both properties are big plusses. Simplicity means scanning code quickly will yield an answer. And the fact that Go makes writing code a chore means there usually isn't that much code.
And of course the fact that Go is so young, means there aren't that many libraries that behave differently. People actually use the standard library features, unlike in Java/C#/C++/Python/... It's becoming less true for net/http, less true for log (all companies I know have their own version, I wonder if Google has it's own version internally too). Go's still in it's honeymoon stage where the standard libraries can actually be used for real projects because they're so young they could implement modern web features without having legacy cruft, nor have they made wrong choices yet, like supporting a dead-end standard or practice.
why is if statement that necessitates multiple assignment statements, involves scoping rules and is objectively bloated for trivial cases, why is it considered simpler?
it sure is easier to get than an operator due to proximity to natural language, but why tend to people that can't grasp that a statement can be represented as an expression?
Think about it: algebra (most of it) is just simple concepts incredibly densely written down and recursively applied. There are very few really complex parts in it, by which I mean there's very few individual steps that take long to understand, there's just so bloody many of them and they link together so incredibly tightly.
The code you gave serves no purpose, so it is difficult to see how it fits into the larger context of a real application, but it may be possible that you don't need an if/else statement like this at all.
a := c
if flag {
a = b
} a := c
and be done with it