inspect()
public
Returns the representation of sym as a symbol literal.
:fred.inspect
Show source
/*
* call-seq:
* sym.inspect => string
*
* Returns the representation of <i>sym</i> as a symbol literal.
*
* :fred.inspect
*/
static VALUE
sym_inspect(sym)
VALUE sym;
{
VALUE str;
const char *name;
ID id = SYM2ID(sym);
name = rb_id2name(id);
str = rb_str_new(0, strlen(name)+1);
RSTRING(str)->ptr[0] = ':';
strcpy(RSTRING(str)->ptr+1, name);
if (!rb_symname_p(name)) {
str = rb_str_dump(str);
strncpy(RSTRING(str)->ptr, ":\"", 2);
}
return str;
}