Skip to content

Commit

Permalink
Fix comment: Buffer.for(string) without block returns readonly buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtm authored and nobu committed May 19, 2024
1 parent cb43540 commit 48ebd77
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions io_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down

0 comments on commit 48ebd77

Please sign in to comment.