Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Add of support for 'unique' method on array wrapper #19

Closed
wants to merge 1 commit into from

Conversation

akinsella
Copy link
Contributor

Hi,

I added some support for 'unique' method on array wrapper.

Here is a sample:

        NSURL *fbReposUrl = [NSURL URLWithString:@"https://api.github.com/orgs/facebook/repos"];
        NSData *data = [NSData dataWithContentsOfURL:fbReposUrl];
        NSArray *repos = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:NULL];

        NSArray *languages = _array(repos).pluck(@"language").reject([Underscore isNull]).unique.unwrap;

        NSLog(@"Unique languages used by FaceBook: %@", languages);


- (USArrayWrapper *)unique;
{
__block NSArray *(^unique)(NSArray *) = ^NSArray *(NSArray *input) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block in not necessary.
I guess you based this on the flatten implementation but there it's just for recursion :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

My mistake. Yes, I based the change on flatten implementation. Do I need to resubmit the pull request ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you can just push to this branch to update the PR, I don't think it makes sense to target development from here.

I suggest you reimplement it based on development and submit a new PR. Sorry for the trouble.

@robb
Copy link
Owner

robb commented Oct 27, 2012

Hi Alexis.

Would you mind addressing my comment and create a new pull request against the development branch?

That branch contains a couple of syntax changes, most notably it adds a functional style for calling methods:

NSArray *myArray = @[@1, @2, @2, @3, @1];
NSArray *uniques = Underscore.unique(myArray);

I'm a bit behind with pushing version 0.2, sorry for that!

Thanks!

@akinsella
Copy link
Contributor Author

Ok,
I'll do it right now.

@robb
Copy link
Owner

robb commented Oct 27, 2012

Cool, I close this Pull Request then

@robb robb closed this Oct 27, 2012
@robb
Copy link
Owner

robb commented Oct 27, 2012

Also, let's call it uniq to be in sync with Haskell, Underscore.js and Unix :-)

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

Successfully merging this pull request may close these issues.

None yet

2 participants