Method: String#-@

Defined in:
string.c

#-Object

Returns a frozen, possibly pre-existing copy of the string.

The returned String will be deduplicated as long as it does not have any instance variables set on it.

[View source]

2777
2778
2779
2780
2781
2782
2783
2784
# File 'string.c', line 2777

static VALUE
str_uminus(VALUE str)
{
    if (!BARE_STRING_P(str) && !rb_obj_frozen_p(str)) {
        str = rb_str_dup(str);
    }
    return rb_fstring(str);
}