String.populate(data) for sprintf?

This idea came up in my mind last night.

As what Kernel::format(format_string, *arguments) is populating the
format string with the data provided by *arguments, isn’t it natural
for a String object (namely the format_string) to receive the
‘populate’ message with the data?

Maybe String.populate_with is better in terms of grammar correctness,
but I thing populate is fine.

A bones question, if you once was a Java developer, do you still
remember Java’s version of sprintf? Maybe this help make more sense of
String.populate()

oops, sorry for typos

^ => does is populating
bones* => bonus question

On Wed, Dec 15, 2010 at 1:22 PM, redstun [email protected] wrote:

As what Kernel::format(format_string, *arguments) is populating the
format string with the data provided by *arguments, isn’t it natural
for a String object (namely the format_string) to receive the
‘populate’ message with the data?

what is wrong w String#%

Hi,

In message “Re: String.populate(data) for sprintf?”
on Wed, 15 Dec 2010 14:49:43 +0900, redstun [email protected]
writes:

|I mean to have String.populate as an instance method
|
|i.e.
|fmt_str = 'aligned numbers: %6d %6d"
|result = fmt_str.populate(1, 2)

fmt_str = “aligned numbers: %6d %6d”
result = fmt_str % [1, 2]

          matz.

Ah, right, so I was just asking for something like

class String
alias :populate :%
end

hmmm, now I’m not sure if this worth the merit of readability

I mean to have String.populate as an instance method

i.e.
fmt_str = 'aligned numbers: %6d %6d"
result = fmt_str.populate(1, 2)

Nothing wrong, just to make things look more natural