diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-21 06:16:07 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-07-21 06:16:07 +0000 |
commit | 6e2850aa46b25d2f76fdd60c7466060f73994a85 (patch) | |
tree | d7a2b4cdc7f69e625206e22e303290e5bdc3f9c7 /sprintf.c | |
parent | 3f606b9aca26a4730559db0021c2bfde667dc281 (diff) | |
download | bundler-6e2850aa46b25d2f76fdd60c7466060f73994a85.tar.gz |
* sprintf.c: add short documentation about named reference.
[ruby-core:31294]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r-- | sprintf.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -420,6 +420,15 @@ get_hash(volatile VALUE *hash, int argc, const VALUE *argv) * sprintf("%1$*2$s %2$d", "hello", -8) #=> "hello -8" * sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23) #=> "+1.23: 1.23:1.23" * sprintf("%u", -123) #=> "-123" + * + * For more complex formatting, Ruby supports a reference by name. + * %<name>s style uses format style, but ${name} style doesn't. + * + * Exapmles: + * sprintf("%<foo>d : %<bar>f" % { :foo => 1, :bar => 2 }) + * #=> 1 : 2.000000 + * sprintf("%d %{foo}" % { :foo => 'bar' }) + * # => "%d bar" */ VALUE |