summaryrefslogtreecommitdiff
path: root/lib/set.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-21 17:03:40 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-21 17:03:40 +0000
commit0fcac8f1a35b73713849db323c206fb4f9aeda5a (patch)
tree8ed0777559edacdce9e031513419993c4296562c /lib/set.rb
parentd02211c9da608742b09aec768db79442007eabc0 (diff)
Avoid use of `self.class.new(self)` in Set#collect!
That prevents infinite recursion when a subclass of Set uses `collect!` in its constructor. This should fix [Bug #12437]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/set.rb')
-rw-r--r--lib/set.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/set.rb b/lib/set.rb
index 05eb3ff..b668738 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -378,7 +378,9 @@ class Set
# Returns an enumerator if no block is given.
def collect!
block_given? or return enum_for(__method__) { size }
- replace(self.class.new(self) { |o| yield(o) })
+ set = self.class.new
+ each { |o| set << yield(o) }
+ replace(set)
end
alias map! collect!