Project

General

Profile

Actions

Misc #10783

open

String#concat has an "appending" behavior

Added by as-cii (Antonio Scandurra) about 9 years ago. Updated over 5 years ago.

Status:
Open
Assignee:
-
[ruby-core:67813]

Description

Ruby String documentation (http://www.ruby-doc.org/core-2.2.0/String.html) introduces the two terms Appending and Concatenation:

  • Concatenation (aka +) —Returns a new String containing other_str concatenated to str.
  • Append (aka <<) —Concatenates the given object to str.

However, calling concat results in an appending operation. I find this particularly confusing and against the Principle of Least Surprise (e.g. I'd expect concat to actually concatenate something). On the other hand I understand that changing such a small method would result in a quite significant breaking change.

Do you see this as an inconsistency? If yes, is there any particular design (or historical) reason behind it?

Thank you.

P.s. Seems like this is the case for Array as well.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0