Forum: Ruby-core [Bug #2725] Return values of Array#compact! and delete: rdoc improvement.

Posted by Hugh Sasse (Guest)
on 2010-02-08 19:42
(Received via mailing list)
Bug #2725: Return values of Array#compact! and delete: rdoc improvement.
http://redmine.ruby-lang.org/issues/show/2725

Author: Hugh Sasse
Status: Open, Priority: Normal
ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]

I wanted further clarification about what happens when items are not 
found when they are expected.  The attached patch meets my needs, 
hopefully those of others.  Documented behaviour checked with irb:

18:32:30$ irb
irb(main):001:0> a = ["pike", "carp", "trout"]
=> ["pike", "carp", "trout"]
irb(main):002:0> a.delete("trout")
=> "trout"
irb(main):003:0> a.delete("herring")
=> nil
irb(main):004:0> a.compact!
=> nil
irb(main):005:0> a.push nil
=> ["pike", "carp", nil]
irb(main):006:0> a.compact!
=> ["pike", "carp"]
irb(main):007:0>
Posted by Yukihiro Matsumoto (Guest)
on 2010-02-09 03:47
(Received via mailing list)
Hi,

In message "Re: [ruby-core:28116] [Bug #2725] Return values of 
Array#compact! and delete: rdoc improvement."
    on Tue, 9 Feb 2010 03:41:46 +0900, Hugh Sasse 
<redmine@ruby-lang.org> writes:

|I wanted further clarification about what happens when items are not found when they are expected.  The attached patch meets my needs, hopefully those of others.  Documented behaviour checked with irb:

Basically agree with your doc patch, but the word "informative" is a
bit subjective, I think.  In addition "get and get" must be a typo,
right?

              matz.
Posted by Hugh Sasse (Guest)
on 2010-02-09 12:21
(Received via mailing list)
Issue #2725 has been updated by Hugh Sasse.

File array_doc_patch added

Spotted a typo (duplicated "and get") in the patch.
The attached is better.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2725
Posted by Hugh Sasse (Guest)
on 2010-02-09 16:48
(Received via mailing list)
Issue #2725 has been updated by Hugh Sasse.


"informative": if compact! succeeds (i.e, makes a
change) it returns the array, otherwise it returns nil.  So this is more 
information about what has happened than using my_array.delete(nil) 
which will
give nil back whatever happens (in one case as the value <i>obj</i> 
passed in, in the other as the standard return value).  Maybe there's a 
better way to put that.

I'm open to suggestions, but maybe the sentence above would suffice? "So 
this is ..."

[I didn't see your post when I spotted the typo as well, I must have 
forgotten to refresh. Thank you
for your attention to detail.]

Thank you.
Hugh
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2725
Posted by Hugh Sasse (Guest)
on 2010-02-15 20:05
(Received via mailing list)
Issue #2725 has been updated by Hugh Sasse.


Do you want me to amend this any further, given that the patch seems to 
have been accepted and merged?
I'm happy for it to be closed now, unless you want improvements.

Thank you,
Hugh
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2725
Posted by Yui NARUSE (Guest)
on 2010-02-16 02:19
(Received via mailing list)
Issue #2725 has been updated by Yui NARUSE.


applied in r26659
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2725
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.