String.populate(data) for sprintf?

R

redstun

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

redstun

[Note: parts of this message were removed to make it a legal post.]

oops, sorry for typos

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

botp

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#%
 
R

redstun

[Note: parts of this message were removed to make it a legal post.]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top