From: Scott Date: 2006-11-11T16:45:08+09:00 Subject: Re: can i shorten up this function ? You may want to consider a little refactoring when you are hard-coding lists into methods. I also notice that you are returning true/false based on a boolean operation. In those cases, returning the result of the boolean operation yields the same value, and cuts out an 'if' statment and 4 lines of code: STATUS_CODES = %w{x j m jrn fnk foo other} def is_valid_code?(status_code) STATUS_CODES.include?(status_code) end is_valid_code?('jrn') -Scott nephish wrote: > hey there, i have a function that checks to see if a string is in a > comma separated list > > it looks like this > def get_in_list(status) > my_list = 'x,j,m,jrn,fnk,foo,other' > my_list_array = my_list.split(',') > if my_list_array.include?(status) > return true > else > return false > end > end > > i dunno, just thought there might be a prettier way to do this. > any suggestions ? > thanks