umka-lang icon indicating copy to clipboard operation
umka-lang copied to clipboard

`append` for maps.

Open ske2004 opened this issue 6 months ago • 3 comments

Title

Edit: This may be not very trivial when keys collide

ske2004 avatar Jun 17 '25 01:06 ske2004

I think append(a, b) should have b overwrite a, and to prioritze you can swap

ske2004 avatar Jun 17 '25 08:06 ske2004

The name append doesn't look right in this case. Maybe a new function like merge? I'm not sure.

Go has offered maps.Copy since 1.18, but it's a type-generic library function:

https://go.dev/play/p/hnaCN1yXHOF

vtereshkov avatar Jun 17 '25 09:06 vtereshkov

The name append doesn't look right in this case. Maybe a new function like merge? I'm not sure.

Go has offered maps.Copy since 1.18, but it's a type-generic library function:

https://go.dev/play/p/hnaCN1yXHOF

It makes sense imo, if you're adding right map to left map the right map will override the keys, appending on top

ske2004 avatar Jun 17 '25 09:06 ske2004