diff options
| author | Yukihiro Matz Matsumoto <[email protected]> | 2013-01-16 18:32:04 +0900 |
|---|---|---|
| committer | Yukihiro Matz Matsumoto <[email protected]> | 2013-01-16 18:32:04 +0900 |
| commit | 79d38c496266faccc9823b396a103c892ee11259 (patch) | |
| tree | 5cc1b15ad2ad97de33a5e85f01f564ba1af2d399 | |
| parent | 98d364e4a692b942d71cb976c034ccaaa6479afc (diff) | |
| download | mruby-79d38c496266faccc9823b396a103c892ee11259.tar.gz mruby-79d38c496266faccc9823b396a103c892ee11259.zip | |
check if array shrinks in each block
| -rw-r--r-- | mrblib/array.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb index 3c4e2dd76..dba32c398 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -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 |
