From 6c61a60609e973f3dec00e86ca6f1519ae83e1e3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 9 Aug 2017 21:20:50 +0900 Subject: Implement `Hash#compact!` in C; ref #3769 --- mrbgems/mruby-hash-ext/mrblib/hash.rb | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'mrbgems/mruby-hash-ext/mrblib/hash.rb') diff --git a/mrbgems/mruby-hash-ext/mrblib/hash.rb b/mrbgems/mruby-hash-ext/mrblib/hash.rb index 640f7daf5..73d1fbe6d 100644 --- a/mrbgems/mruby-hash-ext/mrblib/hash.rb +++ b/mrbgems/mruby-hash-ext/mrblib/hash.rb @@ -130,24 +130,6 @@ class Hash result end - ## - # call-seq: - # hsh.compact! -> hsh - # - # Removes all nil values from the hash. Returns the hash. - # - # h = { a: 1, b: false, c: nil } - # h.compact! #=> { a: 1, b: false } - # - def compact! - result = self.select { |k, v| !v.nil? } - if result.size == self.size - nil - else - self.replace(result) - end - end - ## # call-seq: # hsh.fetch(key [, default] ) -> obj -- cgit v1.2.3