Issue #8688 has been reported by Quintus (Marvin Gülker).

----------------------------------------
Feature #8688: #sprintf should accept strings as keys
https://bugs.ruby-lang.org/issues/8688

Author: Quintus (Marvin Gülker)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


=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 `<main>'}

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



-- 
http://bugs.ruby-lang.org/