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


On 2011-04-15, at 10:08 PM, Steel Steel wrote:

> Using 1.9.1
> I noticed something with chomp
>=20
> $ echo "abc" | ruby -e 'puts gets.chomp("c")'
> abc
>=20
> $ irb
> irb(main):001:0> "abc".chomp("c")
> =3D> "ab"
>=20
> It doesn't work on the command line, or am i doing it wrong.?
> comments?

gets includes the new line (if present):

ratdog:~ mike$ echo "abc" | ruby -e 'puts gets.chomp("c")'
abc
ratdog:~ mike$ echo -n "abc" | ruby -e 'puts gets.chomp("c")'
ab

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)

iEYEARECAAYFAk2o/YcACgkQnsTBwAWZE9rYcACggPbZQh7j9njFyHz7Ri578l4I
nBcAn3OifIruAxP6kfKvikstClASfLFD
=3DlwkT
-----END PGP SIGNATURE-----