summaryrefslogtreecommitdiff
path: root/io_buffer.c
diff options
authorTOMITA Masahiro <tommy@tmtm.org>2024-05-19 20:21:15 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-05-19 23:24:50 +0900
commit48ebd77e595d569b225151ef281aae537d95d6f5 (patch)
tree6e3bd9a86d1490d1deda36f6f0890e072972ca29 /io_buffer.c
parentcb43540d536e378bcac388c730dfdebb404989e7 (diff)
Fix comment: Buffer.for(string) without block returns readonly buffer
Diffstat (limited to 'io_buffer.c')
-rw-r--r--io_buffer.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/io_buffer.c b/io_buffer.c
index 5210d4732b..e6ca61bdae 100644
--- a/io_buffer.c
+++ b/io_buffer.c
@@ -3572,25 +3572,23 @@ io_buffer_not_inplace(VALUE self)
* \Buffer from string:
*
* string = 'data'
- * buffer = IO::Buffer.for(string)
- * # =>
- * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # ...
- * buffer
- * # =>
- * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # 0x00000000 64 61 74 61 data
- *
- * buffer.get_string(2) # read content starting from offset 2
- * # => "ta"
- * buffer.set_string('---', 1) # write content, starting from offset 1
- * # => 3
- * buffer
- * # =>
- * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # 0x00000000 64 2d 2d 2d d---
- * string # original string changed, too
- * # => "d---"
+ * IO::Buffer.for(string) do |buffer|
+ * buffer
+ * # =>
+ * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
+ * # 0x00000000 64 61 74 61 data
+ *
+ * buffer.get_string(2) # read content starting from offset 2
+ * # => "ta"
+ * buffer.set_string('---', 1) # write content, starting from offset 1
+ * # => 3
+ * buffer
+ * # =>
+ * # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
+ * # 0x00000000 64 2d 2d 2d d---
+ * string # original string changed, too
+ * # => "d---"
+ * end
*
* \Buffer from file:
*
close