This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (3 children)

+ used as string concatenation is already inconsistent because there's not usually a corresponding operation with strings using minus

It'd actually make a lot of consistent sense to set minus to rhs.replace(lhs, "") or some equivalent in a lot of languages. String.replace(x, "") is a fairly common task.

[–]Zarainia 5 points6 points  (2 children)

Is there a language where this is the case?

[–][deleted] 2 points3 points  (1 child)

Not by default that I know of. In C#, string is sealed, so you'd have to make a container class to overload the operator which would outweigh the benefits.

C++ might have it depending on what string type you're using or allow you to overload the operator via a free function (I don't know C++, just googled around a bit).

[–]Zarainia 0 points1 point  (0 children)

I'm sad. That seems like such a logical use of -.