[erlang-questions] Newbie question: avoiding massive 'case' statement
Vance Shipley
vances@REDACTED
Wed Mar 5 22:31:59 CET 2008
On Thu, Mar 06, 2008 at 07:59:05AM +1100, David Mitchell wrote:
} try
} &&&TransactionType&&&:process_request(Request)
} catch
} error_logger:info_msg("Unknown transaction type")
} end
}
} where &&&TransactionType&&&:process_request(...) is some "magic code"
receive
TransactionType ->
try
TransactionType:process_request(Request)
catch
_ -> error_logger:info_msg("Unknown transaction type")
end
end
Just send the transaction type as an atom. If you must receive
it as a list use erlang:list_to_existing_atom(TransactionType).
-Vance
More information about the erlang-questions
mailing list