Project

General

Profile

Actions

Feature #14128

open

Introduce Hash#delete default value

Added by gshutler (Garry Shutler) almost 7 years ago. Updated 8 months ago.

Status:
Assigned
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)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0