Just out of curiosity, why are double quotes added to the start and end
of the string when doing String#dump? I can see where it's happening
in string.c, but I don't understand the purpose.
Thanks,
Dan
Just out of curiosity, why are double quotes added to the start and end
of the string when doing String#dump? I can see where it's happening
in string.c, but I don't understand the purpose.
Thanks,
Dan
Daniel Berger wrote:
Just out of curiosity, why are double quotes added to the start and end
of the string when doing String#dump? I can see where it's happening
in string.c, but I don't understand the purpose.
I think it's just for looks, to emphasize that it's a string.
Like String#inspect.
FWIW, I think if you eval a dump, you get the original string back.
I *think* that's correct. But it may be just a side effect.
Hal
Just out of curiosity, why are double quotes added to the start and end
of the string when doing String#dump? I can see where it's happening
in string.c, but I don't understand the purpose.
I venture as my guess that it is merely intended to allow
storing an 'internal' representation of the String. It looks
like all special characters are escaped. This might be useful
for, say, #eval or debugging maybe?
'foo'.dump # => "\"foo\""
"\nf".dump # => "\"\\nf\""
Thanks,
Dan
E
On 2005.12.17 15:37, "Daniel Berger" <djberg96@gmail.com> wrote:
I assumed that _was_ the point of the quotes and the escaping it does ?
On Sat, 17 Dec 2005 06:42:18 -0000, Hal Fulton <hal9000@hypermetrics.com> wrote:
Daniel Berger wrote:
Just out of curiosity, why are double quotes added to the start and end
of the string when doing String#dump? I can see where it's happening
in string.c, but I don't understand the purpose.I think it's just for looks, to emphasize that it's a string.
Like String#inspect.FWIW, I think if you eval a dump, you get the original string back.
I *think* that's correct. But it may be just a side effect.
--
Ross Bamford - rosco@roscopeco.remove.co.uk
nobuyoshi nakada wrote:
Hi,
At Sat, 17 Dec 2005 15:42:18 +0900,
Hal Fulton wrote in [ruby-talk:171286]:I think it's just for looks, to emphasize that it's a string.
Like String#inspect.#dump ignores $KCODE, whereas #inspect is affected by it.
Very interesting. If I ever knew that, I forgot it.
That is the sort of information I am looking for as I learn more
about I18N.
Hal
Ross Bamford wrote:
On Sat, 17 Dec 2005 06:42:18 -0000, Hal Fulton > <hal9000@hypermetrics.com> wrote:
FWIW, I think if you eval a dump, you get the original string back.
I *think* that's correct. But it may be just a side effect.I assumed that _was_ the point of the quotes and the escaping it does ?
It may well be. I've just never seen that documented.
I've rarely used dump anyway.
Hal