From: nobu@... Date: 2016-03-15T02:30:30+00:00 Subject: [ruby-core:74318] [Ruby trunk Bug#12174][Rejected] Interpolation ignores `to_s` (and `inspect`) when `to_s` is defined to `nil`. Issue #12174 has been updated by Nobuyoshi Nakada. Status changed from Open to Rejected Yes, to be interpolated into a string, `to_s` must return a string. Non-string object cannot be concatenated to a string. ---------------------------------------- Bug #12174: Interpolation ignores `to_s` (and `inspect`) when `to_s` is defined to `nil`. https://bugs.ruby-lang.org/issues/12174#change-57438 * Author: Tsuyoshi Sawada * Status: Rejected * Priority: Normal * Assignee: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- When `to_s` is defined to return `nil`, interpolation prints the original inspection. ~~~RUBY class A def to_s; end end puts "#{A.new}" # => # ~~~ It even ignores an overwritten `inspect` definition. ~~~RUBY class A def to_s; end def inspect; "foo" end end puts "#{A.new}" # => # ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: