summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2022-05-05 09:01:12 -0500
committerGitHub <noreply@github.com>2022-05-05 09:01:12 -0500
commitac75c710cccf7adc5b12edc8d18263fef9ab3207 (patch)
treeb75a448acf6e9e0a3b5e32cfbced88ddc2247a89 /doc
parent0b625352196d782e476c8c383e61baa47ab8d3c4 (diff)
Link from printf methods to format spec doc (#5886)
Notes
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/format_specifications.rdoc10
1 files changed, 10 insertions, 0 deletions
diff --git a/doc/format_specifications.rdoc b/doc/format_specifications.rdoc
index 7157220c08..e589524f27 100644
--- a/doc/format_specifications.rdoc
+++ b/doc/format_specifications.rdoc
@@ -336,3 +336,13 @@ Format +argument+ (<tt>'%'</tt>) as a single percent character:
sprintf('%d %%', 100) # => "100 %"
Flags do not apply.
+
+=== Reference by Name
+
+For more complex formatting, Ruby supports a reference by name.
+%<name>s style uses format style, but %{name} style doesn't.
+
+Examples:
+
+ sprintf("%<foo>d : %<bar>f", { :foo => 1, :bar => 2 }) # => 1 : 2.000000
+ sprintf("%{foo}f", { :foo => 1 }) # => "1f"