Skip to content

Commit

Permalink
Use an offensive copy in Array#permutation. Fixes rubinius#775
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Phoenix committed May 2, 2011
1 parent bc0f22e commit 02330f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 9 additions & 1 deletion kernel/common/array.rb
Expand Up @@ -1259,7 +1259,15 @@ def permutation(num=undefined, &block)
perm = Array.new(num)
used = Array.new(@total, false)

__permute__(num, perm, 0, used, &block)
if block
# offensive (both definitions) copy.
offensive = dup
Rubinius.privately do
offensive.__permute__(num, perm, 0, used, &block)
end
else
__permute__(num, perm, 0, used, &block)
end
end

self
Expand Down
1 change: 0 additions & 1 deletion spec/tags/ruby/core/array/permutation_tags.txt

This file was deleted.

0 comments on commit 02330f0

Please sign in to comment.