Or make if… an expression instead of a statement.
Go core are very smart people so I’m sure they have their reasons, but my Lisp-addled brain can’t understand why you’d ever want statements instead of expressions with potentially discarded values.
Go core are very smart people so I’m sure they have their reasons, but my Lisp-addled brain can’t understand why you’d ever want statements instead of expressions with potentially discarded values.
v := if foo() {
7
} else {
11
}
But this means {} blocks now have values, which is weird in a C derivative. Of course, one could do v := func() int {
if foo() {
return 7
} else {
return 11
}
}()
but... that's kind of awful.I sadly don’t see it getting added to Go.