summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2024-07-30 15:31:33 -0500
committerGitHub <[email protected]>2024-07-30 16:31:33 -0400
commitd2b8fd0f37d463399de884fb7fc51fc8157cefd2 (patch)
treeb20872ddaa98f8a9d93884571c72a0663239faed
parent91bb6afa75c2c469aa80dfc988ddc95acbfe75c8 (diff)
[DOC] Tweaks to Array.try_convert (#11260)
Notes
Notes: Merged-By: peterzhu2118 <[email protected]>
-rw-r--r--array.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/array.c b/array.c
index 0b527af3b3..ccf1cd6cc6 100644
--- a/array.c
+++ b/array.c
@@ -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