From: Paul Sutton Date: 2012-06-15T01:05:51+09:00 Subject: Re: Calling methods, getting string and adding them On Thu, 2012-06-14 at 13:32 +0900, Ryan Davis wrote: > On Jun 13, 2012, at 21:28 , Ryan Davis wrote: > > On Jun 13, 2012, at 21:24 , Paul Sutton wrote: > >> Easiest is subjective - but yes, I think string interpolation is in > >> general a better solution when outputting a string. > > > > It is measurable by the number of methods called and the number of garbage objects created. ... > 2111 % ruby -rtracer -e '"a#{1}b#{2}c"' > #0:-e:1::-: "a#{1}b#{2}c" > #0:-e:1:Fixnum:>: "a#{1}b#{2}c" > #0:-e:1:Fixnum:<: "a#{1}b#{2}c" > #0:-e:1:Fixnum:>: "a#{1}b#{2}c" > #0:-e:1:Fixnum:<: "a#{1}b#{2}c" Thank you for the tracer analysis. I did some time benchmarks and it seems to be about 30% faster. I agree completely that interpolation is better. -Paul