Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Return an empty container from select, reject, etc... #34

Closed
mbrandonw opened this issue Oct 5, 2011 · 4 comments
Closed

Return an empty container from select, reject, etc... #34

mbrandonw opened this issue Oct 5, 2011 · 4 comments

Comments

@mbrandonw
Copy link

It seems that a more consistent API choice for the select/reject family of methods is to return an empty container (NSSet, NSArray or NSDictionary) instead of nil when nothing is matched.

Maybe it's too late to change this, but conceptually I think it makes more sense.

@zwaldowski
Copy link
Collaborator

I suppose it would be closer to the API, but BlocksKit isn't just about
wrapping the collection block API's. If it was, then I'd just recommend
using autocomplete and calling it a day. The match/reject family intends to
make code more expressive and declarative. Returning nil allows someone to
just check 'if (!results)' instead of accessing the count property et. al.
You shouldn't be keeping an empty collection around any longer than
absolutely necessary. If you're not getting any results from match/reject
then you should be skipping the code that would be using those results;
conceptually, we're not giving back a set of results that is empty, we're
giving back no results. I do see your point, but I see no practical reason
to break our API.

Thanks for using and contributing to BlocksKit!

@a2 a2 closed this as completed Dec 6, 2011
@zwaldowski zwaldowski reopened this Feb 18, 2012
@zwaldowski
Copy link
Collaborator

I recently heard some rather convincing arguments as per this issue. I think we might change it for the next release.

@mbrandonw
Copy link
Author

Cool, I still stand behind this change.

Brandon Williams

On Saturday, February 18, 2012 at 5:25 PM, Zachary Waldowski wrote:

I recently heard some rather convincing arguments as per this issue. I think we might change it for the next release.


Reply to this email directly or view it on GitHub:
#34 (comment)

@zwaldowski
Copy link
Collaborator

Completed in BlocksKit 1.0.6.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants