diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index aaf008ad..7b2ec144 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -225,17 +225,32 @@ strio_s_allocate(VALUE klass) * call-seq: * StringIO.new(string = '', mode = 'r+') -> new_stringio * - * Note that +mode+ defaults to 'r' if +string+ is frozen. - * * Returns a new \StringIO instance formed from +string+ and +mode+; - * see {Access Modes}[rdoc-ref:File@Access+Modes]: + * the instance should be closed when no longer needed: + * + * strio = StringIO.new + * strio.string # => "" + * strio.closed_read? # => false + * strio.closed_write? # => false + * strio.close + * + * If +string+ is frozen, the default +mode+ is 'r': * - * strio = StringIO.new # => # + * strio = StringIO.new('foo'.freeze) + * strio.string # => "foo" + * strio.closed_read? # => false + * strio.closed_write? # => true * strio.close * - * The instance should be closed when no longer needed. + * Argument +mode+ must be a valid + * {Access Mode}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Access+Modes], + * which may be a string or an integer constant: + * + * StringIO.new('foo', 'w+') + * StringIO.new('foo', File::RDONLY) * - * Related: StringIO.open (accepts block; closes automatically). + * Related: StringIO.open + * (passes the \StringIO object to the block; closes the object automatically on block exit). */ static VALUE strio_initialize(int argc, VALUE *argv, VALUE self)