[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: if-in statement
- From: "Tim Kelly" <gtkelly@...>
- Date: Sun, 11 Nov 2007 21:53:50 +0100 (CET)
> if method in ('HEAD','GET','POST') then ...
Can you use table lookups?
(global)
method_table = {
["HEAD"] = HeadFunction,
["GET"] = GetFunction,
["POST"] = PostFunction
}
(local)
fnc = method_table[method]
res = fnc(bytes, other_params)
(end)
I use this approach to handle calling functions based on the string value.
tim
Gregory T. (tim) Kelly
Owner
Dialectronics.com
"Anything war can do, peace can do better." -- Bishop Desmond Tutu