Palindrome finder

Oops, indeed.

Dan

···

-----Original Message-----
From: Peter Vanbroekhoven [mailto:calamitas@advalvas.be]
Sent: Thursday, September 01, 2005 9:22 AM
To: ruby-talk ML
Subject: Re: palindrome finder

On Fri, 2 Sep 2005, Berger, Daniel wrote:

> That can be shortened to:
>
> IO.foreach("testdict.txt"){ |line|
> line.downcase!.chomp!
> puts line if line == line.reverse?
> }
>
> Note the chomp!

Never chain bang methods:

irb(main):001:0> "hello".downcase!.chomp!
NoMethodError: private method `chomp!' called for nil:NilClass
         from (irb):1

Peter