Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby/Rails passing array to case

Here is the scenario:

case code
  when 'www', '', nil
    false
  when 'code1', 'code2'... 'code_n' # The array STORE_CODES contains all the codes 
    true
  else
    false
end

How can I use STORE_CODES directly after when instead of 'code1', 'code2'... 'code_n'

like image 686
Hable Avatar asked Aug 15 '13 07:08

Hable


1 Answers

just use:

when *STORE_CODES

instead of :

when 'code1', 'code2'... 'code_n'
like image 85
Muntasim Avatar answered Sep 23 '22 05:09

Muntasim