From: Brian Adkins Date: 2008-11-11T09:57:34+09:00 Subject: Re: Comparing variable to multiple values Greg Lazarev writes: > I'm wondering if there's a better way to do this in ruby: > > if a == "word1" || a == "word2" or || a == "word3" > puts "good" > end I realize that you probably want a more general solution (which others have already provided); however, if 'a' *does* follow a pattern: puts 'good' if a =~ /word[1-3]/ or puts 'good' if a =~ /word\d+/ -- Brian Adkins http://www.lojic.com/ http://lojic.com/blog/