Project

General

Profile

Actions

Feature #14128

open

Introduce Hash#delete default value

Added by gshutler (Garry Shutler) over 6 years ago. Updated over 6 years ago.

Status:
Open
Target version:
-
[ruby-core:83870]

Description

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.

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

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

Updated by shevegen (Robert A. Heiler) over 6 years ago

I think this should be filed under features rather than bugs.

Here is a link to the documentation if anyone else wants to have
a look:

https://ruby-doc.org/core/Hash.html#method-i-delete

I am neither pro or con on the suggestion so I will not
comment on it - I only wanted to provide a quick link to
the docu so that others can find the most recent docu +
examples more easily.

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN)

Updated by gshutler (Garry Shutler) over 6 years ago

Sorry, I thought I was recording it as a feature request. Thanks for fixing nobu.

Updated by marcandre (Marc-Andre Lafortune) over 6 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

I am in favor of this.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0