End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Array#inspect
array.inspect → new_string
array.c
View on GitHub ↗
static VALUE
rb_ary_inspect(VALUE ary)
{
if (RARRAY_LEN(ary) == 0) return rb_usascii_str_new2("[]");
return rb_exec_recursive(inspect_ary, ary, 0);
}
Returns the new String formed by calling method inspect on each array element:
Example
a = [:foo, 'bar', 2] a.inspect # => "[:foo, \"bar\", 2]"
Array#to_s is an alias for Array#inspect.