M
Marc Heiler
user_input = $stdin.gets.chomp
case user_input
when 'x'
puts 'this is a test'
end
# So far so fine. Now I want to add something like
when 'y'
puts 'yay, a new test'
end
What would be the simplest or most elegant way?
A hash with key -> action ?
Only problem is that the action could be invoking a method or creating
an object etc... and i dont want to use proc or lambda's at all.
I would just like to "extend" the case menu somehow
(I need to split a huge case menu into "core" modules, and
stuff which a user wants to add to it)
case user_input
when 'x'
puts 'this is a test'
end
# So far so fine. Now I want to add something like
when 'y'
puts 'yay, a new test'
end
What would be the simplest or most elegant way?
A hash with key -> action ?
Only problem is that the action could be invoking a method or creating
an object etc... and i dont want to use proc or lambda's at all.
I would just like to "extend" the case menu somehow
(I need to split a huge case menu into "core" modules, and
stuff which a user wants to add to it)