On Friday, August 12, 2016 at 5:31:07 PM UTC-4, Anmol Sethi wrote:
>
> Keyed fields seem to be always better than unkeyed fields in a composite 
> literal. 
> Under what circumstances would I want to use unkeyed fields?


When it's useful for writing code that is easier to read and comprehend. 
This is similar to using naked returns: some code can be made clearer using 
it; some code can be made more obscure.

I think most valuable use is for large compound literals, e.g. arrays of 
structs:  Key-less specification lets the element literals easier to scan; 
they occupy a narrower visual field.  The labels are redundant.

Jonathan

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to