5

That's gonna be a quick rant about Golang.

Anyone else here frustrated by the fact that you can inline assignment in the if statement, but can't inline the if-else itself?

You can do:
if thing := hey.getThatThing(); thing == theThing {
return 'this'
} else {
return 'that'
}

But can't do:
return 'this' if hey.getTheThing() == theThing else 'that'

Or is it just me using too much Python everyday and connecting that with Go in free time?

Comments
  • 1
    I just can't get used to Go's 'inheritance by composition'.
    Python will remain my favourite language :D
  • 1
    And coz of Python my Go code won't compile... '' is for runes only in Go. Which makes sense, but the string will require "" and therefore the code will not run.

    Usage of '' for keyword strings in Python and "" for human readable strings <3.
  • 1
    Can't return ( foo ===bar)? 'this':'that';?
  • 1
    @nbamaral no, no ternary operator in go
  • 0
    @afrometal Uh that's annoying. I'm missing the ternary operator sometimes in Kotlin. But at least almost everything is an expression, including "if" and "when".
Add Comment