@@ -223,19 +223,34 @@ strio_s_allocate(VALUE klass)
223223
224224/*
225225 * call-seq:
226- * StringIO.new(string = '', mode = 'r+') -> new_stringio
227- *
228- * Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen.
226+ * self.new(string = '', mode = 'r+') -> new_stringio
229227 *
230228 * Returns a new \StringIO instance formed from +string+ and +mode+;
231- * see {Access Modes}[rdoc-ref:File@Access+Modes]:
229+ * the instance should be closed when no longer needed:
230+ *
231+ * strio = StringIO.new
232+ * strio.string # => ""
233+ * strio.closed_read? # => false
234+ * strio.closed_write? # => false
235+ * strio.close
236+ *
237+ * If +string+ is frozen, the default +mode+ is <tt>'r'</tt>:
232238 *
233- * strio = StringIO.new # => #<StringIO>
239+ * strio = StringIO.new('foo'.freeze)
240+ * strio.string # => "foo"
241+ * strio.closed_read? # => false
242+ * strio.closed_write? # => true
234243 * strio.close
235244 *
236- * The instance should be closed when no longer needed.
245+ * Argument +mode+ must be a valid
246+ * {Access Mode}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Access+Modes],
247+ * which may be a string or an integer constant:
248+ *
249+ * StringIO.new('foo', 'w+')
250+ * StringIO.new('foo', File::RDONLY)
237251 *
238- * Related: StringIO.open (accepts block; closes automatically).
252+ * Related: StringIO.open
253+ * (passes the \StringIO object to the block; closes the object automatically on block exit).
239254 */
240255static VALUE
241256strio_initialize (int argc , VALUE * argv , VALUE self )
0 commit comments