From: Rick DeNatale Date: 2007-10-25T03:53:02+09:00 Subject: Re: string method that takes in a regex On 10/24/07, Gregory Seidman wrote: > On Thu, Oct 25, 2007 at 03:06:36AM +0900, Parv G. wrote: > > Hi, > > Is there a string method that takes in a regular expression AND returns > > a boolean value? > > > > Looking at the documentation i can't find a method that meets my > > requirements (very surprising). > > % irb > >> /foo/ === 'foo' > => true although 'foo' === /foo/ => false === is non-symmetric. That said, I think that there are very few cases in Ruby where you actually need an instance of either TrueClass or FalseClass, those being when you want to use the non-shortcut methods | instead of || and & instead of && or the exclusive or operator ^ In these few cases you might have to do (expr == true) & expr2 instead of just expr & expr2 There's also !!expr but be careful with that http://www.therailsway.com/2007/8/1/dangers-of-cargo-culting -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/