[ruby-core:83870] [Ruby trunk Bug#14128] Introduce Hash#delete default value

From: garry@...
Date: 2017-11-23 14:18:24 UTC
List: ruby-core #83870
Issue #14128 has been reported by gshutler (Garry Shutler).

----------------------------------------
Bug #14128: Introduce Hash#delete default value
https://bugs.ruby-lang.org/issues/14128

* Author: gshutler (Garry Shutler)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Mirror `Hash#fetch(key [, default]) → obj` with `Hash#delete(key [, default]) → obj`.

Allows for more concise extraction of a value from a hash with a default.

~~~ ruby
# Currently
a = hash.delete(:a) { 10 }

# Becomes
a = hash.delete(:a, 10)
~~~



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

In This Thread

Prev Next