In the guide, merging records is described like this:
You can use an existing record to “fill in” the values of a new record:
{ a = 2, c = ~FF, ..g } ; g = { a = 1, b = "x", c = ~00 }
{ a = 2, b = "x", c = ~FF }
The value of a
and c
is kept from the original record. Wouldn’t it make more sense for g
to overwrite values existing in both records? This would align more with mainstream languages and is arguably more useful.
To keep the existing behavior, one can just place ..g
before values they don’t want to overwrite. This is exactly how it works in Javascript and is pretty logical:
{ ..g, a = 2, c = ~FF }
; g = { a = 1, b = "x", c = ~00 }
{ a = 2, b = "x", c = ~FF }
And:
{ a = 2, c = ~FF, ..g }
; g = { a = 1, b = "x", c = ~00 }
{ a = 1, b = "x", c = ~00 }