Can we do like the way below? How to process the Regular express in it?

def eat(fruit_code)
  fruit_type =
    case fruit_code
     when 'a'
       Apple
     when 'b'
      Banana
     when 'c'
      Coconut
     when 'o'
      Orange
    end
end

=>

FRUIT_TYPES=
  { 'a' => Apple, 'b' => Banana, 'c' => Coconut, 'o' => Orange }.
    freeze

def eat(fruit_code)
  fruit_type = FRUIT_TYPES[fruit_code]
end

-- 
Posted via http://www.ruby-forum.com/.