Method: Array.try_convert

Defined in:
array.c

.try_convert(object) ⇒ Object?

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.

Returns:



1043
1044
1045
1046
1047
# File 'array.c', line 1043

static VALUE
rb_ary_s_try_convert(VALUE dummy, VALUE ary)
{
    return rb_check_array_type(ary);
}