Skip to content

Commit

Permalink
Return nil when Enumerator#product receives a block
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 17, 2024
1 parent 3ea2847 commit 61659c9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/src/main/ruby/jruby/kernel/enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,14 @@ def Enumerator.product(*enums, **kwargs, &block)
if kwargs && !kwargs.empty?
raise ArgumentError.new("unknown keywords: " + kwargs.keys.map(&:inspect).join(", "))
end
Enumerator::Product.new(*enums).each(&block)
product = Enumerator::Product.new(*enums)

if block_given?
product.each(&block)
return nil
end

product
end

class Enumerator::Product < Enumerator
Expand Down

0 comments on commit 61659c9

Please sign in to comment.