mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[DOC] Tweaks to String::try_convert
This commit is contained in:
parent
ce1dfe81c2
commit
2a55cc3fb8
Notes:
git
2025-04-02 16:03:35 +00:00
Merged: https://github.com/ruby/ruby/pull/13030 Merged-By: peterzhu2118 <peter@peterzhu.ca>
1 changed files with 4 additions and 2 deletions
6
string.c
6
string.c
|
@ -2874,14 +2874,16 @@ rb_check_string_type(VALUE str)
|
|||
* call-seq:
|
||||
* String.try_convert(object) -> object, new_string, or nil
|
||||
*
|
||||
* If +object+ is a +String+ object, returns +object+.
|
||||
* Attempts to convert the given +object+ to a string.
|
||||
*
|
||||
* If +object+ is already a string, returns +object+, unmodified.
|
||||
*
|
||||
* Otherwise if +object+ responds to <tt>:to_str</tt>,
|
||||
* calls <tt>object.to_str</tt> and returns the result.
|
||||
*
|
||||
* Returns +nil+ if +object+ does not respond to <tt>:to_str</tt>.
|
||||
*
|
||||
* Raises an exception unless <tt>object.to_str</tt> returns a +String+ object.
|
||||
* Raises an exception unless <tt>object.to_str</tt> returns a string.
|
||||
*/
|
||||
static VALUE
|
||||
rb_str_s_try_convert(VALUE dummy, VALUE str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue