[Nix-dev] Small Question on Strings, Attributes & Functions

Eelco Dolstra eelco.dolstra at logicblox.com
Wed Aug 24 12:46:37 CEST 2016


Hi,

On 08/24/2016 12:11 PM, Matan Shenhav wrote:

> I was going through the awesome and illuminating Tour of Nix
> <https://nixcloud.io/tour/> when I bumped into a conundrum in doing exercise 33
> <https://nixcloud.io/tour/?id=33>.
> 
> The 'pick' function is meant to return - in a list - the value of attribute 'at'
> in attribute set 'attset':
> 
>     pick = at: attset: if (attset ? at) then [ attset.at ] else []

That should be:

  pick = at: attset: if (attset ? ${at}) then [ attset.${at} ] else []

Note ${...} around "at". Otherwise it tests for an attribute named "at".

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list