From: Mike Stok Date: 2011-04-16T11:23:58+09:00 Subject: Re: chomp behaviour -----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 > > $ echo "abc" | ruby -e 'puts gets.chomp("c")' > abc > > $ irb > irb(main):001:0> "abc".chomp("c") > => "ab" > > 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 - -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk2o/YcACgkQnsTBwAWZE9rYcACggPbZQh7j9njFyHz7Ri578l4I nBcAn3OifIruAxP6kfKvikstClASfLFD =lwkT -----END PGP SIGNATURE-----