Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d0f82efa3946
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c5dcaf08e8e5
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 25, 2016

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    da529d1 View commit details
  2. Copy the full SHA
    c5dcaf0 View commit details
Showing with 8 additions and 3 deletions.
  1. +2 −3 kernel/common/array.rb
  2. +6 −0 spec/ruby/core/array/product_spec.rb
5 changes: 2 additions & 3 deletions kernel/common/array.rb
Original file line number Diff line number Diff line change
@@ -1144,9 +1144,8 @@ def product(*args)
outer_lambda.call([])

if block_given?
block_result = self
result.each { |v| block_result << yield(v) }
block_result
result.each { |v| yield(v) }
self
else
result
end
6 changes: 6 additions & 0 deletions spec/ruby/core/array/product_spec.rb
Original file line number Diff line number Diff line change
@@ -41,6 +41,12 @@
acc.should be_empty
end

it "returns self" do
a = [1, 2, 3].freeze

a.product([1, 2]) { |p| p.first }.should == a
end

it "will ignore unreasonable numbers of products and yield anyway" do
a = (0..100).to_a
lambda do