summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-enumerator/mrblib/enumerator.rb
diff options
context:
space:
mode:
authorksss <[email protected]>2014-03-15 00:03:53 +0900
committerksss <[email protected]>2014-03-15 08:15:16 +0900
commit6b3cc0052d93983cd7cb9ee48a3c4c140046fc2a (patch)
tree24443202e4504aa2f8dc0bfadd2cb48f45125ddf /mrbgems/mruby-enumerator/mrblib/enumerator.rb
parent47fc784b567d58c48ad1f018e3b56926acd76725 (diff)
downloadmruby-6b3cc0052d93983cd7cb9ee48a3c4c140046fc2a.tar.gz
mruby-6b3cc0052d93983cd7cb9ee48a3c4c140046fc2a.zip
fix self modifying bug
Diffstat (limited to 'mrbgems/mruby-enumerator/mrblib/enumerator.rb')
-rw-r--r--mrbgems/mruby-enumerator/mrblib/enumerator.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/mrbgems/mruby-enumerator/mrblib/enumerator.rb b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
index 8641d99e0..cf909bac5 100644
--- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb
+++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
@@ -255,6 +255,7 @@ class Enumerator
# enum.each(:y, :z) { |elm| elm } #=> :method_returned
#
def each *argv, &block
+ obj = self
if 0 < argv.length
obj = self.dup
args = obj.args
@@ -264,9 +265,9 @@ class Enumerator
else
args = argv.dup
end
- @args = args
+ obj.args = args
end
- return self unless block_given?
+ return obj unless block_given?
enumerator_block_call(&block)
end