From: tamouse mailing lists Date: 2012-11-17T12:30:17+09:00 Subject: Re: Alternatives to methods for large number of nested "ifs" On Fri, Nov 16, 2012 at 9:50 AM, botp wrote: > try a chain, eg, > > $ cat test.rb ; echo "--output--"; ruby test.rb > [ > [->{true},->{p "one"}], > [->{1==1}, ->{p "two"}], > [->{false},->{p "no see"}], > [->{true},->{p "wont see light"}], > ].each do |condition, func| > break unless condition.call > func.call > end > > --output-- > "one" > "two" > > best regards -botp > That, right there, is idiomatic ruby.