From: botp Date: 2012-11-17T00:50:14+09:00 Subject: Re: Alternatives to methods for large number of nested "ifs" On Fri, Nov 16, 2012 at 10:35 PM, Philip Rhoades wrote: > if .. > some lines of code > if .. > some lines of code > if .. > some lines of code > if .. > some lines of code > if .. > some lines of code > etc 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