如何让 Ramda 对面?
How to get Ramda opposite?
如何使用 ramda 获得相反的值?我正在尝试归档以下内容:
R.opposite(true) //false
R.opposite(false) // true
正如 Felix 提到的,您可以使用 not 来否定一个值:
A function that returns the ! of its argument. It will return true when passed false-y value, and false when passed a truth-y one.
not(true) //=> false
如果您需要取反函数的结果,您可以使用 complement:
Takes a function f and returns a function g such that if called with the same arguments when f returns a "truthy" value, g returns false and when f returns a "falsy" value g returns true.
complement(equals(true))(true) //=> false
如何使用 ramda 获得相反的值?我正在尝试归档以下内容:
R.opposite(true) //false
R.opposite(false) // true
正如 Felix 提到的,您可以使用 not 来否定一个值:
A function that returns the ! of its argument. It will return true when passed false-y value, and false when passed a truth-y one.
not(true) //=> false
如果您需要取反函数的结果,您可以使用 complement:
Takes a function f and returns a function g such that if called with the same arguments when f returns a "truthy" value, g returns false and when f returns a "falsy" value g returns true.
complement(equals(true))(true) //=> false