[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
mame@ruby-lang.org wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <normalperson@yhbt.net> wrote:
[ruby-core:82593] [Ruby trunk Bug#13855] Hash#compact! returns nil if the hash is empty
From:
shevegen@...
Date:
2017-08-31 18:44:48 UTC
List:
ruby-core #82593
Issue #13855 has been updated by shevegen (Robert A. Heiler).
Hmm.
I had a look at class String and class Array what they do.
First Array:
array = [1,2,3] # => [1, 2, 3]
array.compact! # => nil
Next class String - it has no .compact but perhaps we can use
.delete! which may be somewhat similar:
string = 'abc' # => "abc"
string.delete! 'd' # => nil
So I assume that the nil returned there may be consistent behaviour. Probably
by nature of the assumption of what is returned, modification in place on
the same object, or a modification what would return a new object.
However had I do agree that, either way, the documentation could be more explicit.
No harm in mentioning that the hash.compact! variant will return nil, which is
what it is presently doing.
I do however had also agree that the behaviour may be a bit unexpected... so perhaps
the documentation can be fixed either way and then we can ask whether the behaviour
is the way it should be - but I actually assume that it may be just a documentation
problem.
----------------------------------------
Bug #13855: Hash#compact! returns nil if the hash is empty
https://bugs.ruby-lang.org/issues/13855#change-66414
* Author: elandesign (Paul Smith)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
This behaviour feels like a bug to me.
From the documentation (with my emphasis):
> compact! → hsh
> Removes all nil values from the hash. **Returns the hash**.
However if the hash contains no keys, the method returns nil.
~~~
irb(main):001:0> {}.compact!
=> nil
# For Comparison
irb(main):002:0> { foo: nil }.compact!
=> {}
irb(main):003:0> {}.compact
=> {}
irb(main):004:0> { foo: nil }.compact
=> {}
~~~
--
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>