diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-19 14:03:19 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-19 14:03:19 +0900 |
| commit | 57c7f92dbfedb4476f2dfda401897ee7467a0c38 (patch) | |
| tree | 1aa9e04f5f735876cccc01e83851c163b1a51a34 | |
| parent | d7eb455cf3a2a4c72ee02fa2907718dd24413169 (diff) | |
| parent | 2bf718faf86001c30032cbff152c154135577a54 (diff) | |
| download | mruby-57c7f92dbfedb4476f2dfda401897ee7467a0c38.tar.gz mruby-57c7f92dbfedb4476f2dfda401897ee7467a0c38.zip | |
Merge branch 'master' of github.com:mruby/mruby
| -rw-r--r-- | mrbgems/mruby-enumerator/test/enumerator.rb | 4 | ||||
| -rw-r--r-- | mrblib/enum.rb | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/mrbgems/mruby-enumerator/test/enumerator.rb b/mrbgems/mruby-enumerator/test/enumerator.rb index 45d86685e..c2b4c09ab 100644 --- a/mrbgems/mruby-enumerator/test/enumerator.rb +++ b/mrbgems/mruby-enumerator/test/enumerator.rb @@ -452,6 +452,10 @@ assert 'Enumerable#map' do assert_equal [[1,0],[4,1],[9,4]], c end +assert 'Enumerable#find_all' do + assert_equal [[3,4]], [[1,2],[3,4],[5,6]].find_all.each{ |i| i[1] == 4 } +end + assert 'Array#each_index' do a = [1,2,3] b = a.each_index diff --git a/mrblib/enum.rb b/mrblib/enum.rb index 04a27294c..38c51aa21 100644 --- a/mrblib/enum.rb +++ b/mrblib/enum.rb @@ -146,6 +146,8 @@ module Enumerable # # ISO 15.3.2.2.8 def find_all(&block) + return to_enum :find_all unless block_given? + ary = [] self.each{|*val| ary.push(val.__svalue) if block.call(*val) |
