Issue #8350 has been reported by sawa (Tsuyoshi Sawada).

----------------------------------------
Feature #8350: Extending `%{}` notation in string to accept an array
https://bugs.ruby-lang.org/issues/8350

Author: sawa (Tsuyoshi Sawada)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


=begin
`String#%` accepts a hash as an argument and interpolates the values into `%{}`-notated portions of the string:

    "%{b} said %{a} to %{c}" % {a: "Foo", b: "Bar", c: "Baz"}        #=> "Bar said Foo to Baz"

I would like to have it allow an array as well, where the `%{}`-notation has indices:

    "%{1} said %{0} to %{2}" % ["Foo", "Bar", "Baz"]        #=> "Bar said Foo to Baz"

Of course, since the `%{}` notation interprets its content as a symbol, the following should also work:

    "%{1} said %{0} to %{2}" % {:"0" => "Foo", :"1" => "Bar", :"2" => "Baz"}        #=> "Bar said Foo to Baz"

but that would not cause any conflict.
There is also a different usage of `String#%` with an array argument like this:

    "%-5s: %08x" % [ "ID", self.object_id ]   #=> "ID   : 200e14d6"

but that does not allow the array elements to appear in the string in an order different from as is in the array. The proposed feature is distinct from this, and adds flexibility.
=end


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