How do I turn the following if / else
statement:
if /_?town$/.match? name ['Springfield', 'Shelbyville', 'Kent', 'Carter', 'Benson'].sample elsif /_?state$/.match? name ['TX'].sample else'text' end
into a case
statement in Rails / Ruby?
I tried
case name when /_?town$/.match? ['Springfield', 'Shelbyville', 'Kent', 'Carter', 'Benson'].sample when /_?state$/.match? ['TX'].sample else'text' end
but I am getting a wrong number of arguments error related to match?