These are chat archives for ramda/ramda

3rd
Feb 2019
Mattibun
@Mattibun
Feb 03 00:03

I find myself writing a lot of things like this:

const willStop = model => (R.equals(model.playerStop, R.F) ? R.T : R.F);
// ... hidden bits
() =>  willStop(model) ? enemyStop(model) : removeStop([model, aiPattern])

But because functions are truthy, it will never get to removeStop.

Mattibun
@Mattibun
Feb 03 00:10
It does work if willStop is changed to this to force boolean conversion.
const willStop = model => !!R.equals(model.playerStop, R.F);
Ben Briggs
@ben-eb
Feb 03 00:12
@Mattibun
const willStop = R.propEq('playerStop', false)
Mattibun
@Mattibun
Feb 03 00:12
So never set R.F in my object at all and stick with booleans?
Or will R.F evaulate to false in that instance?
Asad Saeeduddin
@masaeedu
Feb 03 00:14
if that property is already a boolean, why not just use it as the boolean result?
Ben Briggs
@ben-eb
Feb 03 00:15
^ Yep. Plus using T and F in this way confuses the meaning of the code
Asad Saeeduddin
@masaeedu
Feb 03 00:15
in other words const willStop = x => x.playerStop or !x.playerStop, according to whatever you need
Mattibun
@Mattibun
Feb 03 00:19
@masaeedu, I'm setting the property to R.T or R.F right now elsewhere in the code. But it sounds like I should stick with plain true or false.
Yes, that works and is much clearer.
So then why is there T and F in Ramda?
Asad Saeeduddin
@masaeedu
Feb 03 01:16
I think it might just be a shorter way of doing R.always(true) where you need that