From: Lincoln Anderson Date: 2007-01-23T10:26:09+09:00 Subject: Re: Placing tabs in strings in irb -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Nathan Smith wrote: >> >> Actually, I tried this and it gives a string literal back >> >> =>"1\t2\t3\t4" >> >> This occurs as well if inserted into a full ruby script (not just irb). >> >> Lincoln Anderson > > > In irb if you do a="1\t2\t3\t4" it replies with "1\t2\t3\t4". But, if > you do > puts a, it gives you: 1 2 3 4. > > The string must be in double quotes for this to work. > >> On a related note why is the value for the above string '1' if I use >> a.to_i to display it? I would have expected an error. > > Extraneous characters past the end of a valid number are ignored, according > to the docs. > > Nate > Okay, shoulda guessed that the "output" from defining a wouldn't be formatted. And when I check my ruby script I see that I had it single quoted, not double-quoted. Cool, I learneded something today. Lincoln Anderson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFtWQqR8wmeqHdtdcRAgt1AJsHk6tqx8O53aejXnKon5QLWQXSAgCfQ4kg h1hKQ4B+SA44EqchgM6gW+w= =oJNw -----END PGP SIGNATURE-----