[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: "" vs ''

Dominik Bathon

7/21/2006 1:35:00 PM

On Thu, 20 Jul 2006 20:48:09 +0200, Ben Johnson <bjohnson@contuitive.com>
wrote:

> I know this is a very simply question, but I've seen many different
> responses.
>
> Isn't it better to use 'some string' instead of "some string".
> Because the "" goes through a lot more working interpreting any
> variable that might be in the string, etc. Where as '' is just literal.

There is no difference at all after parsing, both get turned into a
NODE_STR (unless there are interpolations):

>> %{"abc"}.parse_to_nodes.transform
=> [:str, {:lit=>"abc"}]
>> %{'abc'}.parse_to_nodes.transform
=> [:str, {:lit=>"abc"}]

And I don't think that there is any significant performance difference
while parsing, so use whatever you like more.


Dominik