Actions
Feature #8688
open#sprintf should accept strings as keys
Status:
Open
Assignee:
-
Target version:
-
Description
=begin
Hi there,
Kernel#sprintf should support strings as keys. Currently it only works with symbols:
{irb(main):001:0> str = "This is %{foo}."
=> "This is %{foo}."
irb(main):002:0> sprintf(str, :foo => "bar")
=> "This is bar."
irb(main):003:0> sprintf(str, "foo" => "bar")
KeyError: key{foo} not found
from (irb):3:in sprintf' from (irb):3 from /opt/rubies/mri/bin/irb:12:in
'}
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
If I want a user to be able to enter format strings and (later) the corresponding parameter values, I don’t want to call #to_sym on the keys (because generating symbols from user input is known to cause memory issues).
Valete,
Marvin
=end
No data to display
Actions
Like0