Method: Weak::Set#intersect?
- Defined in:
- lib/weak/set.rb
#intersect?(enum) ⇒ Bool
Note:
Weak::Set does not test member equality with == or eql?.
Instead, it always checks strict object equality, so that, e.g.,
different strings are not considered equal, even if they may contain
the same string content.
Returns true if self and the given enumerable object have at
least one element in common, false otherwise.
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/weak/set.rb', line 504 def intersect?(enum) case enum when Weak::Set enum_ary = enum.to_a own_ary = to_a if own_ary.size < enum_ary.size own_ary.any?(enum) else enum_ary.any?(self) end else enumerable(enum).any?(self) end end |