Alexey Muranov wrote in post #1019158:
> 7stud -- wrote in post #1019114:
>
>>
>>> inspect returns:
>>>
>>> ruby-1.9.2-p180 :009 > DocType.all.map {|d| d.name.inspect}
>>>   DocType Load (1.4ms)  SELECT "doc_types".* FROM "doc_types"
>>>  => ["\"127.0.0.1\"", "\"127.0.0.1\""]
>>>
>>
>> The output shows that the string is actually "127.0.0.1"--not 127.0.0.1.
>
>
> I disagree,

Okay, I agree with your disagree.  I have no idea what this means, 
though:

> this output shows only that the `inspect` of the string is
> (unquoted) "127.0.0.1", but the string itself is (unquoted) 127.0.0.1.
> So this does not clarify the issue.
>
> Alexey.


strings = [
  "abc",
  %q("abc")
]

results = strings.map do |str|
  str.inspect
end

p results

results.each do |str|
  puts str
end


--output:--
["\"abc\"", "\"\\\"abc\\\"\""]
"abc"
"\"abc\""

The second element in the array is hard to interpret: if you strip away 
what inspect added to the first string, you get:

\\\"abc\\\"

I guess \\ is a literal slash and \' is an escaped quote.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to