From: Tanner Burson Date: 2005-09-02T00:37:10+09:00 Subject: Re: palindrome finder ------=_Part_12373_32290346.1125588765619 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/1/05, Berger, Daniel wrote: >=20 >=20 > > file =3D File.open("testdict.txt", "r" ) do |file| > > file.each_line("\n") do |line| > > #filelist.push( line ) > > line.downcase! > > if (line =3D=3D line.reverse) > > puts line > > end > > end > > end > > > That can be shortened to: >=20 > IO.foreach("testdict.txt"){ |line| > line.downcase!.chomp! > puts line if line =3D=3D line.reverse? > } Which can cause errors for lines that don't include new lines. A safer=20 version would be: IO.foreach("testdict.txt"){ |line| puts line if line.downcase.chomp =3D=3D line.downcase.chomp.reverse } --=20 =3D=3D=3DTanner Burson=3D=3D=3D tanner.burson@gmail.com http://tannerburson.com <---Might even work one day... ------=_Part_12373_32290346.1125588765619--