From: w_a_x_man Date: 2010-10-21T05:10:12+09:00 Subject: Re: Long conditional statements On Oct 20, 2:39 pm, Robert Klemme wrote: > On 20.10.2010 20:37, Courtland Allen wrote: > > > On Wed, Oct 20, 2010 at 11:25 AM, Robert Klemme > > wrote: > >> Courtland, can you demonstrate a real example of your complex conditions? > >>   Maybe there are other ways to transform them and make them less complex. > > It happens in a variety of different ways in my code, so the more techniques > > you guys list, the better (I hadn't known about any?). > > > But here's one example anyway: > > > if somehash[:key1].blank? or somehash[:key2].blank? > >> or somehash[:key2].blank? or somehash[:key2].blank? > > >    doSomething() > > > end > > if [:key1, :key2].any? {|k| somehash[k].blank?} >    do_something > end > > Not much of an improvement though. > if somehash.values_at( :key1, :key2 ).index( "" ) do_something end