diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2022-02-21 12:17:02 +0100 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2022-05-20 11:31:59 -0700 |
commit | 65122d09d515c9183e643d5f7f31d24251b149ed (patch) | |
tree | 4aec21b69ad07bcc3ca0a335df693c5d6c454808 /string.c | |
parent | 11336c7ddb81b619842eed2a9c5a49a5361df24e (diff) |
[Feature #18595] Alias String#-@ as String#dedup
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5583
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -2933,7 +2933,9 @@ str_uplus(VALUE str) * 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. + * any instance variables set on it and is not a String subclass. + * + * String#dedup is an alias for String#-@. */ static VALUE str_uminus(VALUE str) @@ -11879,6 +11881,7 @@ Init_String(void) rb_define_method(rb_cString, "freeze", rb_str_freeze, 0); rb_define_method(rb_cString, "+@", str_uplus, 0); rb_define_method(rb_cString, "-@", str_uminus, 0); + rb_define_alias(rb_cString, "dedup", "-@"); rb_define_method(rb_cString, "to_i", rb_str_to_i, -1); rb_define_method(rb_cString, "to_f", rb_str_to_f, 0); |