-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Result fallback can be a function #1900
Conversation
Result fallback can be a function
It wasn't an oversight, it was deliberate. I guess it depends on what phase you consider the default value. When I think of default value I think of the default fully resolved value. After this merge what the user provides as the default could have further resolving done to it. Side note: This |
Yes — we shouldn't do this. It makes a lot of sense to use |
Thinking on it some more. Normally, without providing a default value, a user has no way of resolving a function property value (the actual function), so maybe it makes sense. It's kind of a wonky case. Imma sip on some coffee and let this marinate. |
This came out of a use case in one of my projects. I can give a couple useful examples of why this may be useful _.result(obj, 'dateCreated', Date.now);
_.result(obj, 'fullName', function() {
return this.firstName + " " + this.lastName;
}); Again, I'm not married to this being included, but there is some nice sugar that can come from it |
Ah, nice. Sorry for the confusion. Go for it if you like it. |
This reverts commit 40e8517.
Personally I think this is an oversight of #1515 and believe this is a complimentary case -- however, this is easy to get around if you disagree