Эта страница ещё не переведена, поэтому показана на английском. Помогите с переводом

fxNot

Boolean negation as a function you can pass around.

bool fxNot(bool a) => !a;

Lecture

fxNot does exactly what !a does — it just does it as a first-class function, so it can be passed where a bool Function(bool) is expected instead of you writing (b) => !b yourself. FxTS's not works on JavaScript "truthy" values of any type; Dart has no implicit truthiness, so the Dart port only accepts an actual bool.

Because its signature is bool -> bool, fxNot doubles as a predicate itself wherever the element type is already bool — see some/every in Demo 2. For negating an arbitrary predicate over some other type, use fxNegate instead.

Demo 1 · Basics

Demo 2 · As a predicate over booleans

fxNot is itself a bool Function(bool), so it plugs straight into some/every without wrapping:

Try it yourself

Exercise: use fxNot to build the list of "still pending" flags from a list of "done" flags.

Related: fxNegate — negate a whole predicate function, not just a bool · some / every — used with not above · fxWhen — conditional transform · fxUnless — the inverse-condition sibling of when