mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
check if array shrinks in each block
This commit is contained in:
+7
-1
@@ -12,7 +12,13 @@ class Array
|
||||
def each(&block)
|
||||
idx, length = -1, self.length-1
|
||||
while(idx < length)
|
||||
block.call(self[idx += 1])
|
||||
elm = self[idx += 1]
|
||||
unless elm
|
||||
if elm == nil and length >= self.length
|
||||
break
|
||||
end
|
||||
end
|
||||
block.call(elm)
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user