Skip to content

Instantly share code, notes, and snippets.

@nefftd
Created June 13, 2014 21:44
Show Gist options
  • Save nefftd/07ee9237579956c24871 to your computer and use it in GitHub Desktop.
Save nefftd/07ee9237579956c24871 to your computer and use it in GitHub Desktop.
argcheck (moonscript)
do
checktypelist = (t,a1,...) ->
t == a1 or checktypelist t,... if a1 ~= nil
export argcheck = (val,argn,...) ->
return if checktypelist type(val),...
types = '/'\join tostringall ...
fname = debug.getinfo(2,'n').name or 'unknown'
error "bad argument ##{tonumber(argn) or '?'} to '#{fname}' (#{types} expected, got #{type val})",3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment