Yes. Declaring i and j on the same line is certainly cleaner. We should all do it like that.
Am I missing something? On Thu, Aug 18, 2022, 9:25 PM Yasser Sinjab <ysin...@gmail.com> wrote: > Thanks, I don't object it personally, but I had a debate about "grouping > variables is considered a clean code". > > Let's say you have the following code: > > var x, y, z string > var i int > > And a new change came as: > > var j int > var x, y, z string > var i int > > For me this is not clean. Group them is cleaner like : > > var i, j int > > > That's of course with the exception that variables should be as close to > the logic it is initialized for. > On Thursday, August 18, 2022 at 7:38:54 PM UTC+3 Brian Candler wrote: > >> There's also a lot of good background about the language design choices >> in the FAQ: >> https://go.dev/doc/faq >> >> Go derives much of its syntax from C, and the FAQ describes some of the >> differences from C. But note that even C allows you to do the same: >> >> int a, b, c; >> char *x, *y, *z; >> >> On Thursday, 18 August 2022 at 17:35:21 UTC+1 Brian Candler wrote: >> >>> What exactly is it about that expression that you don't think seems >>> right? >>> >>> It's a shortcut for: >>> >>> var x string >>> var y string >>> var z string >>> >>> I think that saving typing is a good feature. >>> >>> Or do you object to the feature of being able to declare variables at >>> all? >>> >>> On Thursday, 18 August 2022 at 13:52:56 UTC+1 ysi...@gmail.com wrote: >>> >>>> Hi, >>>> >>>> I'm just wondering why this feature is in Golang: such as >>>> >>>> var x, y, z string >>>> >>>> Thanks, >>>> Yasser >>>> >>> -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/ec5c344a-3a67-49d1-9da7-ec3633cfb903n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/ec5c344a-3a67-49d1-9da7-ec3633cfb903n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CALJzkY-2yzKs_j1cfrm_tzurw5Axpkn6ZG93rSbm5PPsj5UgPA%40mail.gmail.com.