optionalAttrs
lib.attrsets.optionalAttrs
Docs pulled from | This Revision | 34 minutes ago
If cond
is true, return the attribute set as
,
otherwise an empty attribute set.
Inputs
cond
-
Condition under which the
as
attribute set is returned. as
-
The attribute set to return if
cond
istrue
.
Type
optionalAttrs :: Bool -> AttrSet -> AttrSet
Examples
lib.attrsets.optionalAttrs
usage example
optionalAttrs (true) { my = "set"; }
=> { my = "set"; }
optionalAttrs (false) { my = "set"; }
=> { }
Noogle detected
Implementation
The following is the current implementation of this function.
optionalAttrs =
cond:
as:
if cond then as else {};