[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: String performance

Gavin Kistner

1/9/2007 9:02:00 PM

From: George Palmer
> Guys a quick performance question - Is either one of the following
> more efficient than the other? I'm guessing they're in this order:
>
> 'a' + x + 'b'
> "a" + x + "b"
> "a#{x}b"

Despite the intuition, I've never been able to prove that "foo" vs.
'foo' is measurably slower or faster.

String interpolation is, however, faster than either of the above. (I'm
not sure why, but my guess is that it has to do with how many
intermediary strings are created.)