Skip to content

Commit

Permalink
fmap always returns immutable object
Browse files Browse the repository at this point in the history
  • Loading branch information
kkazuo committed Dec 18, 2014
1 parent 8fbd9ff commit 01171b2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions NSArray+map.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ @implementation NSArray (YOLO)
if (o)
mapped[jj++] = o;
}

Class immutableClass = [NSArray class];
Class mutableClass = [NSMutableArray class];
Class cls = [self isKindOfClass:mutableClass] ? mutableClass : immutableClass;
return [[cls alloc] initWithObjects:mapped count:jj];
return [NSArray arrayWithObjects:mapped count:jj];
};
}

Expand Down
2 changes: 1 addition & 1 deletion NSDictionary+fmap.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ @implementation NSDictionary (YOLO)
objs[ii++] = o;
}
}
return [[self.class alloc] initWithObjects:objs forKeys:keys count:ii];
return [NSDictionary dictionaryWithObjects:objs forKeys:keys count:ii];
};
}

Expand Down
2 changes: 1 addition & 1 deletion NSSet+fmap.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ @implementation NSSet (YOLO)
if (o)
mapped[ii++] = o;
}
return [[self.class alloc] initWithObjects:mapped count:ii];
return [NSSet setWithObjects:mapped count:ii];
};
}

Expand Down

0 comments on commit 01171b2

Please sign in to comment.