From: David Alan Black Date: 2002-02-18T20:59:45+09:00 Subject: Re: x =~ /pat/, "return type?" Hello -- On Mon, 18 Feb 2002, David Corbin wrote: > Alexander Schofield wrote: > > >That sounds like your best bet, basically anything not nil or not false > >is true. It can make for shorter code while allowing for a return value > >to have a double meaning-- if it is true, not only return a true value, > >but something that may be useful. > > > >David Alan Black wrote: > > > >>On Mon, 18 Feb 2002, David Corbin wrote: > >> > > > > > >>Or could you get your class to recognize more general true/false > >>equivalences? Or is there some nicer/shorter way to do it > >>I'm not thinking of? :-) > >> > > > Thanks to everyone for the various suggestions. The code I'm calling is > assert() in RubyUnit, so I'm not going to be able to change the libary. > (Well, I could, I suppose, but there are lots of reasons not too...) OK, now that I know the specifics, I can provide a nicer way to do it :-) def test_regex assert_match(/a/, "a") assert_not_match(/a/, "b") end David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav