Method: Object#inspect

Defined in:
object.c

#inspectString

Returns a string containing a human-readable representation of obj. If not overridden and no instance variables, uses the to_s method to generate the string. obj. If not overridden, uses the to_s method to generate the string.

[ 1, 2, 3..4, 'five' ].inspect   #=> "[1, 2, 3..4, \"five\"]"
Time.new.inspect                 #=> "2008-03-08 19:43:39 +0900"

Returns:



# File 'object.c'

static VALUE
rb_obj_inspect(VALUE obj)
{
    if (TYPE(obj) == T_OBJECT && rb_obj_basic_to_s_p(obj)) {
        int has_ivar = 0;
        VALUE *ptr = ROBJECT_IVPTR(obj);
        long len = ROBJECT_NUMIV(obj);
        long i;

        for (i = 0; i < len; i++) {
if (ptr[i] != Qundef) {
    has_ivar = 1;
    break;
}