From: Robert Klemme Date: 2006-11-17T18:25:05+09:00 Subject: Re: case vs using if question On 17.11.2006 08:21, Scott Comboni wrote: > Paul Lutus wrote: >> Scott Comboni wrote: >> >> / ... >> >>> or am i better using >>> if component == 'PC': puts "Postcard" >>> elsif component == 'DC': puts "Decal" >> It depends to some extent on how many comparisons there are. IMHO you >> should >> consider using the case ... when construction for more than a few >> comparisons. >> >> Also, look at case ... when ... then sample code online for the correct >> syntax to use. > > Thanks so much Paul for the quick response.. I have about 100 codes to > search I just converted it to case seems a little cleaner and less > typing which is good.. Thanks for the info.. In that case (!) I would definitively use a Hash as Justin suggested. This is /much/ more efficient and also you gain flexibility in filling that Hash (i.e. load it from some config file vs. making it part of the code) if you need that. Kind regards robert