diff options
author | Burdette Lamar <[email protected]> | 2024-07-30 15:31:33 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-30 16:31:33 -0400 |
commit | d2b8fd0f37d463399de884fb7fc51fc8157cefd2 (patch) | |
tree | b20872ddaa98f8a9d93884571c72a0663239faed | |
parent | 91bb6afa75c2c469aa80dfc988ddc95acbfe75c8 (diff) |
[DOC] Tweaks to Array.try_convert (#11260)
Notes
Notes:
Merged-By: peterzhu2118 <[email protected]>
-rw-r--r-- | array.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1016,14 +1016,17 @@ rb_to_array(VALUE ary) * call-seq: * Array.try_convert(object) -> object, new_array, or nil * - * If +object+ is an +Array+ object, returns +object+. + * Attempts to convert the given +object+ to an +Array+ object: * - * Otherwise if +object+ responds to <tt>:to_ary</tt>, - * calls <tt>object.to_ary</tt> and returns the result. + * - If +object+ is an +Array+ object, returns +object+. + * - Otherwise if +object+ responds to <tt>:to_ary</tt>. + * calls <tt>object.to_ary</tt>: * - * Returns +nil+ if +object+ does not respond to <tt>:to_ary</tt> + * - If the return value is an +Array+ or +nil+, returns that value. + * - Otherwise, raises TypeError. + * + * - Otherwise returns +nil+. * - * Raises an exception unless <tt>object.to_ary</tt> returns an +Array+ object. */ static VALUE |