Project

General

Profile

Bug #10845

Updated by mame (Yusuke Endoh) 8 months ago

If I make a subclass of `String`, the method `*` returns an instance of that class. 

 ~~~ruby 
 class MyString < String 
 end 

 MyString.new("foo").*(2).class #=> MyString 
 ~~~ 

 This is different from other similar operations like `+` and `%`, which return a `String` instance. 

 ~~~ruby 
 MyString.new("foo").+("bar").class #=> String 
 MyString.new("%{foo}").%(foo: 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?

Back