ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:77709] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact!
       [not found] <redmine.issue-12863.20161022082307@ruby-lang.org>
@ 2016-10-22  8:23 ` csonpatki
  2016-10-22  9:03 ` [ruby-core:77710] " zverok.offline
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: csonpatki @ 2016-10-22  8:23 UTC (permalink / raw
  To: ruby-core

Issue #12863 has been reported by Prathamesh Sonpatki.

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

* 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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:77710] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact!
       [not found] <redmine.issue-12863.20161022082307@ruby-lang.org>
  2016-10-22  8:23 ` [ruby-core:77709] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact! csonpatki
@ 2016-10-22  9:03 ` zverok.offline
  2016-10-22  9:10 ` [ruby-core:77711] " zverok.offline
  2016-10-22  9:48 ` [ruby-core:77712] [Ruby trunk Bug#12863] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: zverok.offline @ 2016-10-22  9:03 UTC (permalink / raw
  To: ruby-core

Issue #12863 has been updated by Victor Shepelev.


What is the reason of returning `nil` in that case? I believe in standard containers all bang-versions always return self?

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

* 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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:77711] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact!
       [not found] <redmine.issue-12863.20161022082307@ruby-lang.org>
  2016-10-22  8:23 ` [ruby-core:77709] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact! csonpatki
  2016-10-22  9:03 ` [ruby-core:77710] " zverok.offline
@ 2016-10-22  9:10 ` zverok.offline
  2016-10-22  9:48 ` [ruby-core:77712] [Ruby trunk Bug#12863] " nobu
  3 siblings, 0 replies; 4+ messages in thread
From: zverok.offline @ 2016-10-22  9:10 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:77712] [Ruby trunk Bug#12863] Hash#compact! behavior different from the Active Support Hash#compact!
       [not found] <redmine.issue-12863.20161022082307@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2016-10-22  9:10 ` [ruby-core:77711] " zverok.offline
@ 2016-10-22  9:48 ` nobu
  3 siblings, 0 replies; 4+ messages in thread
From: nobu @ 2016-10-22  9:48 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-22  9:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-12863.20161022082307@ruby-lang.org>
2016-10-22  8:23 ` [ruby-core:77709] [Ruby trunk Misc#12863] Hash#compact! behavior different from the Active Support Hash#compact! csonpatki
2016-10-22  9:03 ` [ruby-core:77710] " zverok.offline
2016-10-22  9:10 ` [ruby-core:77711] " zverok.offline
2016-10-22  9:48 ` [ruby-core:77712] [Ruby trunk Bug#12863] " nobu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).