lua-users home
lua-l archive

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


On Sat, Jun 25, 2011 at 13:21, Rebel Neurofog <rebelneurofog@gmail.com> wrote:
> But that's not the assert () way.
> I can't create assertable function like:
>
> function ob.method ()
>   return func (), get_error
> end
>
> and then call it using assert ()
>
> Kinda no chaining...
>
>

I'm not sure what you mean here exactly. The original assert() can be
written as:
function assert(cond, err)
  if cond then return cond
  else error(err or "assertion failed")
  end
end
So you can write things like foo = assert(getFoo()). As long as any
replacement assert() you write returns cond like this, you can do the
same. Is this what you meant by chaining?

-- 
Sent from my toaster.