lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> if method in ('HEAD','GET','POST') then ...

Can you use table lookups?

method_table = {
   ["HEAD"] = HeadFunction,
   ["GET"] = GetFunction,
   ["POST"] = PostFunction

fnc = method_table[method]

res = fnc(bytes, other_params)


I use this approach to handle calling functions based on the string value.


Gregory T. (tim) Kelly

"Anything war can do, peace can do better."  -- Bishop Desmond Tutu