Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Completely OT but, after 5 years of writing Go, TIL you can assign multiple LHS from multiple RHS:

c1, c2 := a[i], b[i]




Well, duh... I mean, that's the same mechanism that allows a function to return multiple values, and Go prides itself on its orthogonal features, so of course you can do that. Also handy for swapping: "x, y = y, x". Go isn't always more verbose than other languages...




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: