[ruby-core:77712] [Ruby trunk Bug#12863] Hash#compact! behavior different from the Active Support Hash#compact!

From: nobu@...
Date: 2016-10-22 09:48:03 UTC
List: ruby-core #77712
Issue #12863 has been updated by Nobuyoshi Nakada.

Tracker changed from Misc to Bug
Backport set to 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN

----------------------------------------
Bug #12863: Hash#compact! behavior different from the Active Support Hash#compact!
https://bugs.ruby-lang.org/issues/12863#change-60993

* Author: Prathamesh Sonpatki
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
Hash#compact and Hash#compact! were added in https://bugs.ruby-lang.org/issues/11818 but the Hash#compact! is different from Active Support. Please check following snippet:

~~~ ruby
# Active Support
>> hash = { a: true, b: false, c: nil }
=> {:a=>true, :b=>false, :c=>nil}
>> hash.compact!
=> {:a=>true, :b=>false}
>> hash.compact!
=> nil

# Ruby dev

>> hash = { a: true, b: false, c: nil }
=> {:a=>true, :b=>false, :c=>nil}
>> hash.compact!
=> {:a=>true, :b=>false}
>> hash.compact!
=> {:a=>true, :b=>false}
>> 
~~~

@nobu Was it intentional to not return nil in case of compact! when none of the values are nil?





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

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next