-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 2011-05-01, at 3:12 PM, Geometric Patterns wrote:

> Hi.
>=20
> I want to create a string with the backslash character followed by the
> number 37.  Whenever I try to do this, ruby always creates "\037" !
>=20
> e.g. in irb:
>=20
>>> string =3D "\37"
> =3D> "\037"
>=20
> How can I avoid this?   I tried different quoting, escaping, etc.
>=20
> I am missing something fundamental here :-(
>=20
> Any advice gratefully received.

What different quoting did you try? There are a couple of ways to start =
looking at this - if you need to use double quotes then you can escape =
the backslash, and if you don't need to use double quotes then the =
number of things the backslash escapes are reduced.  You should also be =
aware that irb's result display is different from what you'd see with =
puts.  For example:

>> string =3D '\37'
=3D> "\\37"
>> puts string
\37
=3D> nil
>> string =3D "\\37"
=3D> "\\37"
>> puts string
\37
=3D> nil

Hope this helps,

Mike

- --=20

Mike Stok <mike / stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)

iEYEARECAAYFAk29txgACgkQnsTBwAWZE9qwRgCdFd5Dbzf7QoE0xIXSuHBTZjHZ
DqQAoI3/GPmDa89kwIVJH5CeXu633YU9
=3D7UUs
-----END PGP SIGNATURE-----