summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-array-ext/mrblib/array.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-05-14 10:39:41 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-05-14 10:39:41 +0900
commit9422fdbc87cc5310d7f0d5b1b9039fae1b6aa425 (patch)
treeda08caa68d1f15c26735aaffd01ca95eaf2c3e66 /mrbgems/mruby-array-ext/mrblib/array.rb
parentbdb5d85adce53a0639b8cb722c1a8571dd5fd58c (diff)
downloadmruby-9422fdbc87cc5310d7f0d5b1b9039fae1b6aa425.tar.gz
mruby-9422fdbc87cc5310d7f0d5b1b9039fae1b6aa425.zip
mruby-array-ext/array.c: implement `Array#compact` in C.
Diffstat (limited to 'mrbgems/mruby-array-ext/mrblib/array.rb')
-rw-r--r--mrbgems/mruby-array-ext/mrblib/array.rb35
1 files changed, 0 insertions, 35 deletions
diff --git a/mrbgems/mruby-array-ext/mrblib/array.rb b/mrbgems/mruby-array-ext/mrblib/array.rb
index 47446181e..79fcca34e 100644
--- a/mrbgems/mruby-array-ext/mrblib/array.rb
+++ b/mrbgems/mruby-array-ext/mrblib/array.rb
@@ -294,41 +294,6 @@ class Array
end
end
- ##
- # call-seq:
- # ary.compact -> new_ary
- #
- # Returns a copy of +self+ with all +nil+ elements removed.
- #
- # [ "a", nil, "b", nil, "c", nil ].compact
- # #=> [ "a", "b", "c" ]
- #
- def compact
- result = self.dup
- result.compact!
- result
- end
-
- ##
- # call-seq:
- # ary.compact! -> ary or nil
- #
- # Removes +nil+ elements from the array.
- # Returns +nil+ if no changes were made, otherwise returns
- # <i>ary</i>.
- #
- # [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ]
- # [ "a", "b", "c" ].compact! #=> nil
- #
- def compact!
- result = self.select { |e| !e.nil? }
- if result.size == self.size
- nil
- else
- self.replace(result)
- end
- end
-
# for efficiency
def reverse_each(&block)
return to_enum :reverse_each unless block