Method: Wordlist::ListMethods#intersect

Defined in:
lib/wordlist/list_methods.rb

#intersect(other) ⇒ Operators::Intersect Also known as: &

Lazily enumerates over every word that belongs to both wordlists.

Examples:

wordlist1 = Wordlist::Words["foo", "bar", "baz", "qux"]
wordlist2 = Wordlist::Words["xyz", "bar", "abc", "qux"]
(wordlist1 & wordlist2).each do |word|
  puts word
end
# bar
# qux

Parameters:

  • other (Enumerable)

    The other wordlist to intersect with.

Returns:

Since:

  • 1.0.0



151
152
153
# File 'lib/wordlist/list_methods.rb', line 151

def intersect(other)
  Operators::Intersect.new(self,other)
end