From: kjana@...4lab.to (YANAGAWA Kazuhisa) Date: 2002-09-24T12:25:48+09:00 Subject: Re: another easy one... In message <5.1.0.14.2.20020923141722.04f2ba40@zcard04k.ca.nortel.com> probertm@nortelnetworks.com writes: > $ cat blah.rb > c = "C" > case c > when c =~ /[A-Za-z0-9_]/ > puts "yip!" > else > puts "nope..." > end > > $ ruby !$ > ruby blah.rb > nope... > > $ ruby -v > ruby 1.7.2 (2002-07-02) [i386-mswin32] On a case statement, `when foo' does equality check by foo.===. In your code this means `(Fixnum or nil) === c', that's not your intension, is it? Case matching against Regexp should be written: case c when /[A-Za-z0-9_]/ puts "match" else puts "nope!" end where /[A-Za-z0-9_]/.===, that's mere alias of Regexp#=~, will be called. -- kjana@dm4lab.to September 24, 2002 No gains without pains.