Method: Array#&
- Defined in:
- lib/source/ruby.rb
#&(ary) ⇒ Object
call-seq:
ary & other -> array
Set Intersection – returns a new array containing elements common to ary and other, with no duplicates.
[1,1,3,5] & [1,2,3] #=> [1, 3]
1741 1742 1743 1744 |
# File 'lib/source/ruby.rb', line 1741 def &(ary) `for(var i=0,l=this.length,result=[],found=false,seen={};i<l;++i){var a=this[i],k=a.m$hash();for(var j=0,m=ary.length;j<m;++j){var b=this[j];if(a.m$_eql2(b)){found=true;break;};};if(found&&!seen[k]){seen[k]=true;result.push(a);found=false;};}` return `result` end |