tazjin/nix-1p

Adding examples (or additional explanation) for the merge operator .

Closed this issue ยท 5 comments

Lines 129 - 132 the merge operator.

| `left // right`      | Merge `left` & `right` attribute sets, with the right set taking precedence |

Make sure to understand the `//`-operator, as it is used quite a lot and is
probably the least familiar one.

The note says to focus on the merge operator and to make sure to understand it but no real examples are provided nor is merge discussed in the rest of the document.

Is there a way we could add a solid example or two, or perhaps an additional section explaining how/why to use merge.

I think I understand it but feel explaining the operator more would be very helpful. Especially after making a point of adding the note stating to make sure to understand it. Also searching for // is a pain.

The nix docs don't really explain merge either.

{ x = 1; y = 2; } // { z = 3; }

Merge two sets (attributes in the right-hand set taking precedence)

Thanks!

Hey! Yes, good point, I think I'll add a little section about it (also mentioning that it doesn't do recursive merges etc.).

Wow, thanks for the quick response! That would be awesome.

I read the doc and it is a great quick intro to nix. Thanks for putting it together ๐Ÿ™‚

Thanks, glad to hear it :)

New section is pending review here: https://cl.tvl.fyi/c/depot/+/9599/

New section and examples look great. The examples are succinct and easy to understand.

Thanks for the insane turnaround time on adding this ๐Ÿ™‚

Thanks for the insane turnaround time on adding this

When you work for a big company it's nice to keep some personal projects around which let you move fast ;)