String#dump and quotes

Discussion in 'Ruby' started by Daniel Berger, Dec 17, 2005.

  1. 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, Dec 17, 2005
    #1
    1. Advertising

  2. Daniel Berger

    Hal Fulton Guest

    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
     
    Hal Fulton, Dec 17, 2005
    #2
    1. Advertising

  3. LS0tLS1CRUdJTiBQR1AgU0lHTkVEIE1FU1NBR0UtLS0tLQ0KSGFzaDogU0hBMQ0KDQpPbiAyMDA1
    LjEyLjE3IDE1OjM3LCAiRGFuaWVsIEJlcmdlciIgPGRqYmVyZzk2QGdtYWlsLmNvbT4gd3JvdGU6
    DQo+IEp1c3Qgb3V0IG9mIGN1cmlvc2l0eSwgd2h5IGFyZSBkb3VibGUgcXVvdGVzIGFkZGVkIHRv
    IHRoZSBzdGFydCBhbmQgZW5kDQo+IG9mIHRoZSBzdHJpbmcgd2hlbiBkb2luZyBTdHJpbmcjZHVt
    cD8gIEkgY2FuIHNlZSB3aGVyZSBpdCdzIGhhcHBlbmluZw0KPiBpbiBzdHJpbmcuYywgYnV0IEkg
    ZG9uJ3QgdW5kZXJzdGFuZCB0aGUgcHVycG9zZS4NCg0KSSB2ZW50dXJlIGFzIG15IGd1ZXNzIHRo
    YXQgaXQgaXMgbWVyZWx5IGludGVuZGVkIHRvIGFsbG93DQpzdG9yaW5nIGFuICdpbnRlcm5hbCcg
    cmVwcmVzZW50YXRpb24gb2YgdGhlIFN0cmluZy4gSXQgbG9va3MNCmxpa2UgYWxsIHNwZWNpYWwg
    Y2hhcmFjdGVycyBhcmUgZXNjYXBlZC4gVGhpcyBtaWdodCBiZSB1c2VmdWwNCmZvciwgc2F5LCAj
    ZXZhbCBvciBkZWJ1Z2dpbmcgbWF5YmU/DQoNCiAgJ2ZvbycuZHVtcCAgIyA9PiAiXCJmb29cIiIN
    CiAgIlxuZiIuZHVtcCAgIyA9PiAiXCJcXG5mXCIiDQoNCj4gVGhhbmtzLA0KPiANCj4gRGFuDQoN
    Cg0KRQ0KLS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0NClZlcnNpb246IEdudVBHIHYxLjQu
    MSAoR05VL0xpbnV4KQ0KDQppRDhEQlFGRG83MEx4dkExbDZoK01VTVJBbGdTQUo5UTdHK2k3T3JV
    dG1tMVAxZUU2N21iQnpIbVNRQ2dpYndkDQpmSjdmZmZLMVRQMVNYZklCdWFQeXZjND0NCj1kTTFu
    DQotLS0tLUVORCBQR1AgU0lHTkFUVVJFLS0tLS0NCg==
     
    Eero Saynatkari, Dec 17, 2005
    #3
  4. Daniel Berger

    Hal Fulton Guest

    Ross Bamford wrote:
    > On Sat, 17 Dec 2005 06:42:18 -0000, Hal Fulton
    > <> 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
     
    Hal Fulton, Dec 17, 2005
    #4
  5. Daniel Berger

    Hal Fulton Guest

    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
     
    Hal Fulton, Dec 19, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,852
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,645
    Oisin
    Mar 24, 2006
  3. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,497
    Andrew Thompson
    Dec 24, 2003
  4. halfdog
    Replies:
    12
    Views:
    12,456
  5. jOhn
    Replies:
    1
    Views:
    226
    Phlip
    Jan 29, 2008
Loading...

Share This Page