Method: Weak::Set#&
- Defined in:
- lib/weak/set.rb
#&(enum) ⇒ Weak::Set Also known as: intersection
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 a new weak set containing elements common to self
and the given enumerable object.
293 294 295 296 297 298 299 |
# File 'lib/weak/set.rb', line 293 def &(enum) new_set = self.class.new do_with_enum(enum) do |obj| new_set.add(obj) if include?(obj) end new_set end |