Like in python, I’d like to do something like
a = b = c = 10
Currently, I am doing it like
var a, b, c = 10, 10, 10
but the problem with this approach is that I’d have to repeat myself.
Is there any shorter way, so that I don’t have to repeat myself ?
This kind of repetition is so tiny, that you can just ignore it.
It is always good advice to use a programming language as its design intended it to be used. Don’t try to program Python or Java or any other language using Go. When using Go, program Go.
If you repeat yourself for more values then use a loop and set them all to a slice or something. Otherwise, assigning some values to a few variables is fine. In Go, we love explicitness other than anything.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.