class method
Array.try_convert
[U] (untyped) -> ::Array[U]?
Array.try_convert(object) → object, new_array, or nil
array.c
View on GitHub ↗
static VALUE
rb_ary_s_try_convert(VALUE dummy, VALUE ary)
{
return rb_check_array_type(ary);
}
Attempts to return an array, based on the given object.
If object is an array, returns object.
Otherwise if object responds to :to_ary. calls object.to_ary: if the return value is an array or nil, returns that value; if not, raises TypeError.
Otherwise returns nil.
Related: see Methods for Creating an Array.