Email55555 wrote:

> Hi,
> I do not like to check the source code to see what exactly happend.
> Could you tell me, is there a performance different between string
> "..." and '...' for simple string no parameter substitute.
> 
> For example, I saw a lot of code like :
> 
> puts "This is a String."  # case (1)
> which is exactely the same as
> puts 'This is a String.'   # case (2)
> 
> It seems to me most programmer always use "..."
> no matter it has parameter subsitute or not.
> 
> I like to know for simple string, like example above,
> the case #2 will "faster" then case #1 ?
> 
> ( if yes, I will "set up" my habit, when a simple string
> always use '...' )
> 
> Thanks for your help.

Try putting it in a loop and see what happens.  For me:

g0@spud:~$ time ruby -e "5000000.times {'This is a String.'}"

real    0m8.467s
user    0m8.470s
sys     0m0.000s
g0@spud:~$ time ruby -e "5000000.times {'This is a String.'}"

real    0m8.419s
user    0m8.410s
sys     0m0.010s
g0@spud:~$ time ruby -e "5000000.times {'This is a String.'}"

real    0m8.391s
user    0m8.390s
sys     0m0.000s
g0@spud:~$ time ruby -e '5000000.times {"This is a String."}'

real    0m8.445s
user    0m8.430s
sys     0m0.010s
g0@spud:~$ time ruby -e '5000000.times {"This is a String."}'

real    0m8.424s
user    0m8.420s
sys     0m0.010s
g0@spud:~$ time ruby -e '5000000.times {"This is a String."}'

real    0m8.445s
user    0m8.440s
sys     0m0.000s

which suggests there isn't really any practical difference (if my tests are 
valid).  Actually, unless there are cases where '...' is noticably quicker, 
perhaps it'd be more convenient to just make '...' and "..." identical (a 
la python)?