--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The argument for the complaint is that keyed composite literals are more future-proof. If you later change the layout of s, the code will fail to compile if the keys no longer work, but an unkeyed literal may compile incorrectly. In your example, if you swapped a and b in s, the first assignment of z would set 1 to b and 2 to a.
On Thu, Jan 7, 2016 at 2:21 AM, Tamás Gulácsi <tgula...@gmail.com> wrote:
Add keys - for
type s struct{a,b int}
Instead of z :=s{1,2}
Use z :=s{a:1,b:2}
--
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 golan...@googlegroups.com.