Project

General

Profile

Actions

Feature #18595

closed

Alias `String#-@` as `String#dedup`

Added by byroot (Jean Boussier) over 2 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:107682]

Description

This is a rescoped feature request for https://bugs.ruby-lang.org/issues/16295

Rationale

Unary operator have some precedence oddities (@headius (Charles Nutter))

This often force to use parentheses, which is awkward and breaks the chaining flow.

It's really not obvious what it does. I submitted many pull requests to various open source projects to reduce their memory footprint, and I am constantly asked what it does and I have to point to the String#-@ documentation. The last example was 3 days ago.

I believe that String#dedup would help users discover this feature, and in projects where 3.2 is the oldest supported version, it would allow for much clearer code.

Proposal

It's all in the title: Alias String#-@ as String#dedup.

Or maybe even rename String#-@ as String#dedup, and make String#-@ the alias?


Related issues 2 (1 open1 closed)

Related to Ruby master - Feature #16295: Chainable aliases for String#-@ and String#+@ClosedActions
Related to Ruby master - Feature #16150: Add a way to request a frozen string from to_sOpenActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0