[#67346] Future of test suites for Ruby — Charles Oliver Nutter <headius@...>

I'll try to be brief so we can discuss all this. tl;dr: RubySpec is

19 messages 2015/01/05

[ruby-core:67818] [ruby-trunk - Misc #10783] String#concat has an "appending" behavior

From: me@...
Date: 2015-01-26 18:20:32 UTC
List: ruby-core #67818
Issue #10783 has been updated by Antonio Scandurra.


Tsuyoshi Sawada wrote:
> I can't find the place in the documentation that says "Concatenation (aka=
 +)". Is this your own claim? If so, then that is not incorrect.

I'll copy over the relevant excerpts.

~~~
str + other_str =E2=86=92 new_str
Concatenation=E2=80=94Returns a new String containing other_str concatenate=
d to str.
~~~

~~~
str << integer =E2=86=92 str
str << obj =E2=86=92 str
Append=E2=80=94Concatenates the given object to str. If the object is a Int=
eger, it is considered as a codepoint, and is converted to a character befo=
re concatenation.
~~~

But then `concat` is defined as:

~~~
concat(integer) =E2=86=92 str
concat(obj) =E2=86=92 str
Append=E2=80=94Concatenates the given object to str. If the object is a Int=
eger, it is considered as a codepoint, and is converted to a character befo=
re concatenation.
~~~

I summarized what I had read in the documentation, therefore it was not an =
exact quote.=20

----------------------------------------
Misc #10783: String#concat has an "appending" behavior
https://bugs.ruby-lang.org/issues/10783#change-51226

* Author: Antonio Scandurra
* Status: Open
* Priority: Normal
* Assignee:=20
----------------------------------------
Ruby String documentation (http://www.ruby-doc.org/core-2.2.0/String.html) =
introduces the two terms **Appending** and **Concatenation**:

- Concatenation (aka `+`) =E2=80=94Returns a new String containing other_st=
r concatenated to str.
- Append (aka `<<`) =E2=80=94Concatenates the given object to str.=20

However, calling `concat` results in an appending operation. I find this pa=
rticularly confusing and against the Principle of Least Surprise (e.g. I'd =
expect `concat` to actually concatenate something). On the other hand I und=
erstand that changing such a small method would result in a quite significa=
nt 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.



--=20
https://bugs.ruby-lang.org/

In This Thread

Prev Next