From: 13 Date: 2006-03-22T04:25:16+09:00 Subject: Re: "str1" == "STR1" case insensitive Hi, My suggestion is to write a simple convinience method such as: def are_equal(str1, str2) str1.casecmp(str2) == 0 end irb(main):023:0> if are_equal('foo', 'Foo') irb(main):024:1> puts 'equal' irb(main):025:1> else irb(main):026:1* puts 'not equal' irb(main):027:1> end equal -- Martins On 3/21/06, Jacob Fugal wrote: > On 3/21/06, Shea Martin wrote: > > For doing case insensitive comparisons, I have been using > > > > if str1.casecmp(str2)==0 > > puts 'equal' > > else > > puts 'not equal' > > end > > > > Is their a way to do this with simpler syntax? > > I find String#downcase convenient for these sorts of comparisons: > > if str1.downcase == str2.downcase > puts 'equal' > else > puts 'not equal' > end > > Jacob Fugal > >