From: "byroot (Jean Boussier)" Date: 2022-11-14T12:03:38+00:00 Subject: [ruby-core:110753] [Ruby master Feature#19128] Hash#delete could take a second argument as the default value? Issue #19128 has been updated by byroot (Jean Boussier). @dorianmariefr if you wish for this feature to be considered, you'll need to expand a bit on your description. Like providing a few snippets of code that show how it is helpful, how often and how it makes your code better. Bonus point if you can link to open source code that would benefit from this. Once that is said, I personally wanted this a bunch of time. As mentioned by others, in most case `hash.delete(:foo) || default` works fine, but sometimes explicit `nil` or `false` may be expected, in which case you have to use `hash.delete(:foo) if hash.key?(:foo)`. Also as @nobu mentioned, `Hash#delete` already handle a "default block" like fetch, so I think it would make sense to accept a positional default too, just for consistency's sake. ---------------------------------------- Feature #19128: Hash#delete could take a second argument as the default value? https://bugs.ruby-lang.org/issues/19128#change-100091 * Author: dorianmariefr (Dorian Mari��) * Status: Open * Priority: Normal ---------------------------------------- e.g. `{}.delete(:a, [])` would return `[]` -- https://bugs.ruby-lang.org/ Unsubscribe: