tazjin / nix-1p

A (more or less) one page introduction to Nix, the language.
https://code.tvl.fyi/about/nix/nix-1p
896 stars 24 forks source link

Language usage of the "?" character #18

Open WayneSherman opened 7 months ago

WayneSherman commented 7 months ago

The first occurrence of the "?" character is in the table of language operators. As an operator, the "?" usage is defined as: set ? attribute Test whether attribute set contains an attribute

The second occurrence of "?" is used is for the example code: { name, age ? 42 }: "${name} is ${toString age} years old"

I found this confusing because this usage does not agree with the operator definition.

Since the "?" character can also be used to define default values in function parameter declarations, please add a comment, note, or definition of that usage.