`propOr`/`pathOr` inconsistency
See original GitHub issuepropOr('bar', 'foo')({ foo: undefined }); // -> undefined
pathOr('bar', ['foo'])({ a: undefined }); // -> 'bar'
Both propOr
and pathOr
define themselves as returning the value if it is non-null; else the ‘or’ value. These two functions should consistently handle undefined
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
Inconsistency effects in source memory and compensatory ...
Results show an inconsistency effect in source memory accompanied by a compensatory schema-consistent guessing bias when expectancy strength is high, that is, ...
Read more >Your Inconsistency Is More Noticeable Than You Think - Forbes
A study on how your consistency affects your performance at work. Your fellow workers are watching you more than you realize.
Read more >Inconsistency - Logically Fallacious
In terms of a fallacious argument, two or more propositions are asserted that cannot both possibly be true. In a more general sense,...
Read more >Embracing Inconsistency - Drew Amoroso
We've been taught that inconsistency, and flip-flopping, and making decisions that are inconsistent with one another is a sign of lack of focus, ......
Read more >Inconsistency Fallacy Logic & Examples - Study.com
Inconsistency fallacy is a statement that is a contradiction. In such cases, the argument or stance is often erroneous or flawed mainly because ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not sure if I should piggy-back on this or open a new issue. I get that it behaves the way the docs say it does, but I am not convinced that this is the right approach.
To restate the issue:
propOr
returns the default if it fails ahasOwnValue
check, butpathOr
returns the default if the path lookup returnsa falsy valuenull
,undefined
, orNaN
. (thanks for the correction @Bradcomp)I find this to be confusing and inconsistent.
The similarity in the fn names would make you think intuitively that they behave the same way.
Personally, I think I prefer the way this is handled in
R.pathOr
because it seems more intuitive. Its like usingR.path(...)
OR (||
) the default.(Note: its not immediately clear to me how/if this relates to https://github.com/ramda/ramda/issues/1712, apologies if this is a dupe)
@nfantone: I’m going to try very hard to get a release out this weekend. That should be part of it.