class Wordlist::Operators::Concat

Lazily enumerates over the first wordlist, then the second.

@since 1.0.0

Public Instance Methods

each(&block) click to toggle source

Enumerates over each word in both wordlists.

@yield [word]

The given block will be passed each word from both wordlists.

@yieldparam [String] word

A word from one of the wordlists.

@return [Enumerator]

If no block is given, an Enumerator object will be returned.

@example

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

@api public

# File lib/wordlist/operators/concat.rb, line 39
def each(&block)
  return enum_for(__method__) unless block

  @left.each(&block)
  @right.each(&block)
end