From: "nobu (Nobuyoshi Nakada)" Date: 2012-11-21T23:50:17+09:00 Subject: [ruby-core:49814] [ruby-trunk - Feature #3450] Format Strings with Named Arguments & Hash#default Issue #3450 has been updated by nobu (Nobuyoshi Nakada). I think this is a trade-off. Silently ignoring undefined keys may not preferable for somebody. I don't think differentiating simple default value and default proc is good idea. ---------------------------------------- Feature #3450: Format Strings with Named Arguments & Hash#default https://bugs.ruby-lang.org/issues/3450#change-33398 Author: runpaint (Run Paint Run Run) Status: Assigned Priority: Low Assignee: nobu (Nobuyoshi Nakada) Category: core Target version: next minor =begin Is it intentional that the, undocumented, feature #442 (named arguments in format strings) ignores the Hash's default value? >> hash = {greeting: 'Hello'}.tap{|h| h.default = 'World'} >> '%{greeting}, %{greeted}' % hash #=> KeyError: key{greeted} not found It's quite common for templates to use default values. In interface localisation, untranslated strings may need to be substituted for the equivalent in the native language, or replaced with a generic string in the target language. When building reports with format strings, a default value of an empty string allows unexpanded format sequences to be non-fatal. In both cases, a default proc would provide even further flexibility. Another perspective is that this behavior unnecessarily breaks the abstraction that default values are just like any other. =end -- http://bugs.ruby-lang.org/