diff options
| author | takahashim <[email protected]> | 2015-09-16 02:57:41 +0900 |
|---|---|---|
| committer | takahashim <[email protected]> | 2015-09-16 02:57:41 +0900 |
| commit | b88ca625ab44a063c9b105f06789446f791c8b3e (patch) | |
| tree | 87238bbad6dda8b0d5681c95307bd2ad245ce6ee /mrbgems | |
| parent | e91b7d640c8ac6af08f4571e71bb867b62fc4445 (diff) | |
| download | mruby-b88ca625ab44a063c9b105f06789446f791c8b3e.tar.gz mruby-b88ca625ab44a063c9b105f06789446f791c8b3e.zip | |
fix block variable in Hash#fetch
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-hash-ext/mrblib/hash.rb | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-hash-ext/test/hash.rb | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/mrbgems/mruby-hash-ext/mrblib/hash.rb b/mrbgems/mruby-hash-ext/mrblib/hash.rb index c970b9d02..5056d0720 100644 --- a/mrbgems/mruby-hash-ext/mrblib/hash.rb +++ b/mrbgems/mruby-hash-ext/mrblib/hash.rb @@ -126,7 +126,7 @@ class Hash def fetch(key, none=NONE, &block) unless self.key?(key) if block - block.call + block.call(key) elsif none != NONE none else diff --git a/mrbgems/mruby-hash-ext/test/hash.rb b/mrbgems/mruby-hash-ext/test/hash.rb index e1afdaaa3..4950ef354 100644 --- a/mrbgems/mruby-hash-ext/test/hash.rb +++ b/mrbgems/mruby-hash-ext/test/hash.rb @@ -75,6 +75,7 @@ assert('Hash#fetch') do assert_equal "feline", h.fetch("cat") assert_equal "mickey", h.fetch("mouse", "mickey") assert_equal "minny", h.fetch("mouse"){"minny"} + assert_equal "mouse", h.fetch("mouse"){|k| k} begin h.fetch("gnu") rescue => e |
