On Sat, Aug 13, 2016 at 12:06 AM, Anmol Sethi wrote:
> Thing is, since keyed fields are almost always better, why were unkeyed
> fields even allowed for struct literals? I see what you mean in your example,
> but I think it would be simpler to only have unkeyed fields.
>
> Was it a mistake or is
Thing is, since keyed fields are almost always better, why were unkeyed fields
even allowed for struct literals? I see what you mean in your example, but I
think it would be simpler to only have unkeyed fields.
Was it a mistake or is there a even better reason?
> On Aug 12, 2016, at 10:12 PM, N
Unkeyed can be good to remind future you that you've changed the signature
of a struct and are now not populating all the fields. That cuts both
ways, since it means you *have* to go to every place you've created a value
of that struct and update it with a new value... but it also means that if
On Sat, Aug 13, 2016 at 7:29 AM, 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?
Keyed fields are better than unkeyed fields since keyed fields are
covered by the Go1 compatibi
My bad. I should have specified that I meant struct literals.
> On Aug 12, 2016, at 6:02 PM, Ian Lance Taylor wrote:
>
> On Fri, Aug 12, 2016 at 2:29 PM, Anmol Sethi wrote:
>> Keyed fields seem to be always better than unkeyed fields in a composite
>> literal.
>> Under what circumstances would
On Fri, Aug 12, 2016 at 2:29 PM, 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?
Keys aren't always useful, e.g.,
var colors = [...]string{"red", "blue", "green", "yellow"}
I
Keyed fields seem to be always better than unkeyed fields in a composite
literal.
Under what circumstances would I want to use unkeyed fields?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emai