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 <redstun@gmail.com> wrote:

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()

what is wrong w String#%

···

On Wed, Dec 15, 2010 at 1:22 PM, redstun <redstun@gmail.com> 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?

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

···

On Wed, Dec 15, 2010 at 1:36 PM, botp <botpena@gmail.com> wrote:

On Wed, Dec 15, 2010 at 1:22 PM, redstun <redstun@gmail.com> 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 <redstun@gmail.com> 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

···

On Dec 15, 2:38 pm, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:

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

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

                                                    matz\.