Bug #11772
closedImplicit conversion of Array in String interpolation does not call to_str
Description
While providing an example in https://bugs.ruby-lang.org/issues/10930#note-7 I found that the implicit changing of an Array calls to_s without trying to_str first. Isn't String interpolation "implicitly" converting items to strings?
I believe String interpolation should call to_str before to_s
Updated by danielpclark (Daniel P. Clark) almost 11 years ago
My main point here is that anything that happens within String interpolation is "implicitly" going to be a String. So shouldn't it call to_str before to_s on anything given?
Should work as this does.
I also realize that having Ruby lookup two methods to_str and then to_s may slow it down and that we don't want to make it slower. Since Ruby is optimized for to_s being called first I think it would be okay to have to_str called second. Even though by definition you would think that an "implicit" method would be the first method called.
Updated by duerst (Martin Dürst) almost 11 years ago
- Status changed from Open to Closed
As (implicitly) requested at ruby-core:71843.