[#85940] [Ruby trunk Bug#14578] Forking a child process inside of a mutex crashes the ruby interpreter — ben.govero@...
Issue #14578 has been reported by bengovero (Ben Govero).
3 messages
2018/03/05
[#86205] [Ruby trunk Feature#14618] Add display width method to String for CLI — aycabta@...
SXNzdWUgIzE0NjE4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGF5Y2FidGEgKGF5Y2FidGEgLikuCgot
3 messages
2018/03/19
[#86366] Re: [ruby-cvs:70102] usa:r63008 (trunk): get rid of test error/failure on Windows introduced at r62955 — Eric Wong <normalperson@...>
[email protected] wrote:
3 messages
2018/03/28
[ruby-core:85992] [Ruby trunk Feature#14546] Hash#delete!
From:
rringler@...
Date:
2018-03-08 04:42:04 UTC
List:
ruby-core #85992
Issue #14546 has been updated by rringler (Ryan Ringler).
sawa (Tsuyoshi Sawada) wrote:
> What is wrong with using `fetch`?
>
> ```ruby
> {a: "a"}.fetch(:b) # => KeyError: key not found: :b
> ```
Hash#fetch is not mutative. This proposal is for a whiny version of #delete.
```ruby
hsh = { a: 'a' }; hsh.delete!(:a); hsh # => {}
hsh = { a: 'a' }; hsh.delete!(:b); hsh # => KeyError (key not found: :b)
```
----------------------------------------
Feature #14546: Hash#delete!
https://bugs.ruby-lang.org/issues/14546#change-70856
* Author: rringler (Ryan Ringler)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
----------------------------------------
Hash#delete currently returns nil if a given key is not found in the hash. It would be nice to have a way to check that the key was present in the hash. This can be accomplished with with a block, but it would be nice to have some sugar for this.
~~~ ruby
{ a: 'a' }.delete(:b) # => nil
{ a: 'a' }.delete(:b) { |key| raise KeyError, "key not found #{key}" } # => KeyError (key not found: b)
~~~
I'd like to propose a Hash#delete! method:
~~~ruby
{ a: 'a' }.delete!(:a) # => 'a'
{ a: 'a' }.delete!(:b) # => KeyError (key not found: :b)
~~~
---Files--------------------------------
hash_delete_bang.patch (2.37 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>