Skip to content

Commit d71e171

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Tweaks for String#%
1 parent ce8f7da commit d71e171

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

string.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,20 +2912,22 @@ rb_str_times(VALUE str, VALUE times)
29122912

29132913
/*
29142914
* call-seq:
2915-
* string % object -> new_string
2915+
* self % object -> new_string
29162916
*
2917-
* Returns the result of formatting +object+ into the format specification +self+
2918-
* (see Kernel#sprintf for formatting details):
2917+
* Returns the result of formatting +object+ into the format specifications
2918+
* contained in +self+
2919+
* (see {Format Specifications}[rdoc-ref:format_specifications.rdoc]):
29192920
*
2920-
* "%05d" % 123 # => "00123"
2921+
* '%05d' % 123 # => "00123"
29212922
*
2922-
* If +self+ contains multiple substitutions, +object+ must be
2923-
* an Array or Hash containing the values to be substituted:
2923+
* If +self+ contains multiple format specifications,
2924+
* +object+ must be an array or hash containing the objects to be formatted:
29242925
*
2925-
* "%-5s: %016x" % [ "ID", self.object_id ] # => "ID : 00002b054ec93168"
2926-
* "foo = %{foo}" % {foo: 'bar'} # => "foo = bar"
2927-
* "foo = %{foo}, baz = %{baz}" % {foo: 'bar', baz: 'bat'} # => "foo = bar, baz = bat"
2926+
* '%-5s: %016x' % [ 'ID', self.object_id ] # => "ID : 00002b054ec93168"
2927+
* 'foo = %{foo}' % {foo: 'bar'} # => "foo = bar"
2928+
* 'foo = %{foo}, baz = %{baz}' % {foo: 'bar', baz: 'bat'} # => "foo = bar, baz = bat"
29282929
*
2930+
* Related: see {Methods for Converting to New String}[rdoc-ref:String@Methods+for+Converting+to+New+String].
29292931
*/
29302932

29312933
static VALUE

0 commit comments

Comments
 (0)