From: 6ftdan@... Date: 2015-12-05T05:32:55+00:00 Subject: [ruby-core:71843] [Ruby trunk - Bug #11772] Implicit conversion of Array in String interpolation does not call to_str Issue #11772 has been updated by Daniel P. Clark. I realize now that this may be a confrontational issue as the discussion on Symbol#to_str was refused https://bugs.ruby-lang.org/issues/7849 And Jeremy Kemper's description in https://bugs.ruby-lang.org/issues/7342 of "When an object responds to #to_str, it's saying "I am a string." When an object responds to #to_s, it's saying 'I have a string representation.'" So I may have suggested this too quickly :-/ ---------------------------------------- Bug #11772: Implicit conversion of Array in String interpolation does not call to_str https://bugs.ruby-lang.org/issues/11772#change-55246 * Author: Daniel P. Clark * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- 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? ~~~ruby class Array def to_str "Hello from Array!" end end "#{[1,2,3,4,5]}" # => [1, 2, 3, 4, 5] ~~~ I believe String interpolation should call `to_str` before `to_s` -- https://bugs.ruby-lang.org/