Skip to content

Commit 48ebd77

Browse files
tmtmnobu
authored andcommitted
Fix comment: Buffer.for(string) without block returns readonly buffer
1 parent cb43540 commit 48ebd77

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

io_buffer.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,25 +3572,23 @@ io_buffer_not_inplace(VALUE self)
35723572
* \Buffer from string:
35733573
*
35743574
* string = 'data'
3575-
* buffer = IO::Buffer.for(string)
3576-
* # =>
3577-
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
3578-
* # ...
3579-
* buffer
3580-
* # =>
3581-
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
3582-
* # 0x00000000 64 61 74 61 data
3583-
*
3584-
* buffer.get_string(2) # read content starting from offset 2
3585-
* # => "ta"
3586-
* buffer.set_string('---', 1) # write content, starting from offset 1
3587-
* # => 3
3588-
* buffer
3589-
* # =>
3590-
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
3591-
* # 0x00000000 64 2d 2d 2d d---
3592-
* string # original string changed, too
3593-
* # => "d---"
3575+
* IO::Buffer.for(string) do |buffer|
3576+
* buffer
3577+
* # =>
3578+
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
3579+
* # 0x00000000 64 61 74 61 data
3580+
*
3581+
* buffer.get_string(2) # read content starting from offset 2
3582+
* # => "ta"
3583+
* buffer.set_string('---', 1) # write content, starting from offset 1
3584+
* # => 3
3585+
* buffer
3586+
* # =>
3587+
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
3588+
* # 0x00000000 64 2d 2d 2d d---
3589+
* string # original string changed, too
3590+
* # => "d---"
3591+
* end
35943592
*
35953593
* \Buffer from file:
35963594
*

0 commit comments

Comments
 (0)