Formatted strings

suggest change

Ruby can inject an array of values into a string by replacing any placeholders with the values from the supplied array.

"Hello %s, my name is %s!" % ['World', 'br3nt']
# => "Hello World, my name is br3nt!"

The placeholders are the two %s markers. The values come from ['World', 'br3nt']. % tells the string to substitute them. A named or positional format such as %{name} and %1$s is also available; this example uses the array form.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents