[ruby-core:70721] [Ruby trunk - Misc #11520] [Rejected] Inconsistent behavior in Array#compact!

From: nobu@...
Date: 2015-09-11 01:25:04 UTC
List: ruby-core #70721
Issue #11520 has been updated by Nobuyoshi Nakada.

Status changed from Open to Rejected

----------------------------------------
Misc #11520: Inconsistent behavior in Array#compact!
https://bugs.ruby-lang.org/issues/11520#change-54106

* Author: Hal Brodigan
* Status: Rejected
* Priority: Normal
* Assignee: 
----------------------------------------
I noticed that `Array#compact!` sometimes returns `self` and other times `nil`. This behavior was a bit confusing.

    [].compact!
    # => nil
    
    [1].compact!
    # => nil
    
    [nil].compact!
    # => []
    
    [1, nil].compact!
    # => [1]

I would prefer that `Array#compact!` either always returns `nil`, or always returns `self`.



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next