[#77789] [Ruby trunk Feature#12012] Add Boolean method — prodis@...
Issue #12012 has been updated by Fernando Hamasaki de Amorim.
4 messages
2016/10/27
[ruby-core:77711] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact!
From:
zverok.offline@...
Date:
2016-10-22 09:10:01 UTC
List:
ruby-core #77711
Issue #12863 has been updated by Victor Shepelev.
Hm, looks like returning `nil` (if nothing was dropped) is standard behavior of [Hash#reject!](https://ruby-doc.org/core-1.9.3/Hash.html#method-i-reject-21). Weird.
----------------------------------------
Misc #12863: Hash#compact! behavior different from the Active Support Hash#compact!
https://bugs.ruby-lang.org/issues/12863#change-60992
* Author: Prathamesh Sonpatki
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
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:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>