ActionsLike0
Bug #10845
closedSubclassing String
Description
If I make a subclass of String
, the method *
returns an instance of that class.
class MyString < String
end
MyString.new("foo").*(2).class #=> MyString
This is different from other similar operations like +
and %
, which return a String
instance.
MyString.new("foo").+("bar").class #=> String
MyString.new("%{foo}").%(foo: "bar").class #=> String
I don't see clear reason why *
is to be different from +
and %
, and thought that perhaps either the behaviour with *
is a bug, or the behaviour with +
and %
is a bug.
Or, is a reason why they are different?
Updated by marcandre (Marc-Andre Lafortune) almost 10 years ago
- Assignee set to matz (Yukihiro Matsumoto)
Updated by nobu (Nobuyoshi Nakada) almost 10 years ago
- Has duplicate Bug #11209: [PATCH] Fix for String#+ when subclassed added
Updated by mame (Yusuke Endoh) over 5 years ago
- Related to Bug #6087: How should inherited methods deal with return values of their own subclass? added
Updated by jeremyevans0 (Jeremy Evans) over 4 years ago
- Status changed from Open to Closed
ActionsLike0