shawn bright
11/11/2006 6:50:00 AM
Bryan Smith wrote:
> Simply chaining together what you have already provided:
>
> def get_in_list(status)
> 'x,j,m,jrn,fnk,foo,other'.split(',').include?(status)
> end
>
> Don't know how pretty a hand-coded, comma-delimited string is, though. =)
>
>
> Cheers,
> Bryan
>
> On 11/11/06, nephish <nephish@gmail.com> 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
> >
> >
> >
much better, thanks. the list is an example of a string in a database.
yeah, ugly.
thanks again
sk