Re: sunday afternoon whishlist
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: sunday afternoon whishlist
- From: Michal Kottman <k0mpjut0r@...>
- Date: 2010年6月02日 20:43:09 +0200
On Wed, 2010年06月02日 at 09:22 -0700, Stuart P. Bentley wrote:
> If you find you're having a lot of trouble with functions taking the wrong
> number of parameters, consider using this:
>
> function argchecked(f, numargs)
> return function(...)
> if select('#',...)==numargs then f(...)
> else error(string.format(
> "%i arguments expected, got %i",
> numargs,select('#',...))) end
> end
> end
>
Great function, I like it... Just to be complete - it should include a
'return', i.e.:
function argchecked(f, numargs)
return function(...)
if select('#',...)==numargs then return f(...)
else error(string.format(
"%i arguments expected, got %i",
numargs,select('#',...))) end
end
end