Skip to content
Browse files

Fix incorrect results from `Array#intersect`. [#841 state:resolved] (…

…Alexey Bass, Yaffle, Victor)
  • Loading branch information...
1 parent eac97a0 commit 191f458ae8531a3be8e8bedf1385fc1d4f6bf7ef @savetheclocktower savetheclocktower committed Mar 4, 2012
Showing with 2 additions and 1 deletion.
  1. +1 −1 src/prototype/lang/array.js
  2. +1 −0 test/unit/array_test.js
View
2 src/prototype/lang/array.js
@@ -358,7 +358,7 @@ Array.from = $A;
**/
function intersect(array) {
return this.uniq().findAll(function(item) {
- return array.detect(function(value) { return item === value });
+ return array.indexOf(item) !== -1;
});
}
View
1 test/unit/array_test.js
@@ -131,6 +131,7 @@ new Test.Unit.Runner({
testIntersect: function(){
this.assertEnumEqual([1,3], [1,1,3,5].intersect([1,2,3]));
+ this.assertEnumEqual([0,1], [0,1,2].intersect([0,1]));
this.assertEnumEqual([1], [1,1].intersect([1,1]));
this.assertEnumEqual([], [1,1,3,5].intersect([4]));
this.assertEnumEqual([], [1].intersect(['1']));

0 comments on commit 191f458

Please sign in to comment.
Something went wrong with that request. Please try again.