String#dump and quotes

D

Daniel Berger

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
 
H

Hal Fulton

Daniel said:
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
 
E

Eero Saynatkari

LS0tLS1CRUdJTiBQR1AgU0lHTkVEIE1FU1NBR0UtLS0tLQ0KSGFzaDogU0hBMQ0KDQpPbiAyMDA1
LjEyLjE3IDE1OjM3LCAiRGFuaWVsIEJlcmdlciIgPGRqYmVyZzk2QGdtYWlsLmNvbT4gd3JvdGU6
DQo+IEp1c3Qgb3V0IG9mIGN1cmlvc2l0eSwgd2h5IGFyZSBkb3VibGUgcXVvdGVzIGFkZGVkIHRv
IHRoZSBzdGFydCBhbmQgZW5kDQo+IG9mIHRoZSBzdHJpbmcgd2hlbiBkb2luZyBTdHJpbmcjZHVt
cD8gIEkgY2FuIHNlZSB3aGVyZSBpdCdzIGhhcHBlbmluZw0KPiBpbiBzdHJpbmcuYywgYnV0IEkg
ZG9uJ3QgdW5kZXJzdGFuZCB0aGUgcHVycG9zZS4NCg0KSSB2ZW50dXJlIGFzIG15IGd1ZXNzIHRo
YXQgaXQgaXMgbWVyZWx5IGludGVuZGVkIHRvIGFsbG93DQpzdG9yaW5nIGFuICdpbnRlcm5hbCcg
cmVwcmVzZW50YXRpb24gb2YgdGhlIFN0cmluZy4gSXQgbG9va3MNCmxpa2UgYWxsIHNwZWNpYWwg
Y2hhcmFjdGVycyBhcmUgZXNjYXBlZC4gVGhpcyBtaWdodCBiZSB1c2VmdWwNCmZvciwgc2F5LCAj
ZXZhbCBvciBkZWJ1Z2dpbmcgbWF5YmU/DQoNCiAgJ2ZvbycuZHVtcCAgIyA9PiAiXCJmb29cIiIN
CiAgIlxuZiIuZHVtcCAgIyA9PiAiXCJcXG5mXCIiDQoNCj4gVGhhbmtzLA0KPiANCj4gRGFuDQoN
Cg0KRQ0KLS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0NClZlcnNpb246IEdudVBHIHYxLjQu
MSAoR05VL0xpbnV4KQ0KDQppRDhEQlFGRG83MEx4dkExbDZoK01VTVJBbGdTQUo5UTdHK2k3T3JV
dG1tMVAxZUU2N21iQnpIbVNRQ2dpYndkDQpmSjdmZmZLMVRQMVNYZklCdWFQeXZjND0NCj1kTTFu
DQotLS0tLUVORCBQR1AgU0lHTkFUVVJFLS0tLS0NCg==
 
H

Hal Fulton

Ross said:
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
 
H

Hal Fulton

nobuyoshi said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top