From e962c9c4c3a45729831a497fee8190ca121bef78 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Sat, 24 Aug 2024 15:57:47 +0100 Subject: [PATCH] [DOC] Tweaks to Array#compact! --- array.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/array.c b/array.c index bbfaa3cef4..3b6920b0a4 100644 --- a/array.c +++ b/array.c @@ -6285,11 +6285,17 @@ rb_ary_uniq(VALUE ary) /* * call-seq: - * array.compact! -> self or nil + * compact! -> self or nil * - * Removes all +nil+ elements from +self+. + * Removes all +nil+ elements from +self+; + * Returns +self+ if any elements are removed, +nil+ otherwise: * - * Returns +self+ if any elements removed, otherwise +nil+. + * a = [nil, 0, nil, false, nil, '', nil, [], nil, {}] + * a.compact! # => [0, false, "", [], {}] + * a # => [0, false, "", [], {}] + * a.compact! # => nil + * + * Related: Array#compact. */ static VALUE