ifElse
Using ifElse in functional pipelines (3 min. read)
We'll cover the following...
We'll cover the following...
We’re used to seeing if statements like this
An increasingly popular alternative is the ternary statement.
Ramda provides ifElse, letting you handle branching logic with functions.
One advantage is that you can package the logic away into a function. Instead of hardcoding the hasAccess variable, make it a parameter.
And instead of the console.log side-effect, purify it by simply returning your desired result.
This makes a point-free style easier to achieve.
And the end result’s easier to test!