Feature #14128

Introduce Hash#delete default value

Added by gshutler (Garry Shutler) about 3 years ago. Updated about 3 years ago.

Target version:


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) about 3 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:

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.


Updated by nobu (Nobuyoshi Nakada) about 3 years ago

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

Updated by gshutler (Garry Shutler) about 3 years ago

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

Updated by marcandre (Marc-Andre Lafortune) about 3 years ago

  • Assignee set to matz (Yukihiro Matsumoto)

I am in favor of this.

Also available in: Atom PDF