lua-users home
lua-l archive

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


I usually do:

if condition then call_my_routine() else return end
if the resulting line is short, or:

if condition then
   call_my_routine()
else
   return
end
If it doesn't fit nicely in one line (usually because the body is more than one statement). However when the body is a single statement but doesn't fit on a line (because the condition is long), I sometimes do:
if condition
   then call_my_routine()
   else return
end
especially if it's several elif with complex conditions, eg:

if complex_condition_1
then do_thing_1
elif complex_condition_2
then do_thing_2
else return
end

What's most important is that the code is readable and not hideous to look at, rather than sticking strictly to one style at all times.