Skip to content

Commit cc90adb

Browse files
[DOC] Tweaks for String#append_as_bytes
1 parent a188249 commit cc90adb

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

string.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4173,25 +4173,27 @@ rb_str_concat_multi(int argc, VALUE *argv, VALUE str)
41734173

41744174
/*
41754175
* call-seq:
4176-
* append_as_bytes(*objects) -> string
4176+
* append_as_bytes(*objects) -> self
41774177
*
4178-
* Concatenates each object in +objects+ into +self+ without any encoding
4179-
* validation or conversion and returns +self+:
4178+
* Concatenates each object in +objects+ into +self+; returns +self+;
4179+
* performs no encoding validation or conversion:
41804180
*
41814181
* s = 'foo'
4182-
* s.append_as_bytes(" \xE2\x82") # => "foo \xE2\x82"
4183-
* s.valid_encoding? # => false
4182+
* s.append_as_bytes(" \xE2\x82") # => "foo \xE2\x82"
4183+
* s.valid_encoding? # => false
41844184
* s.append_as_bytes("\xAC 12")
4185-
* s.valid_encoding? # => true
4185+
* s.valid_encoding? # => true
41864186
*
4187-
* For each given object +object+ that is an Integer,
4188-
* the value is considered a Byte. If the Integer is bigger
4189-
* than one byte, only the lower byte is considered, similar to String#setbyte:
4187+
* When a given object is an integer,
4188+
* the value is considered an 8-bit byte;
4189+
* if the integer occupies more than one byte (i.e,. is greater than 255),
4190+
* appends only the low-order byte (similar to String#setbyte):
41904191
*
41914192
* s = ""
4192-
* s.append_as_bytes(0, 257) # => "\u0000\u0001"
4193+
* s.append_as_bytes(0, 257) # => "\u0000\u0001"
4194+
* s.bytesize # => 2
41934195
*
4194-
* Related: String#<<, String#concat, which do an encoding aware concatenation.
4196+
* Related: see {Modifying}[rdoc-ref:String@Modifying].
41954197
*/
41964198

41974199
VALUE

0 commit comments

Comments
 (0)