[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Extending assert () functionality
- From: HyperHacker <hyperhacker@...>
- Date: Sat, 25 Jun 2011 16:04:04 -0600
On Sat, Jun 25, 2011 at 13:21, Rebel Neurofog <firstname.lastname@example.org> wrote:
> But that's not the assert () way.
> I can't create assertable function like:
> function ob.method ()
> return func (), get_error
> and then call it using assert ()
> Kinda no chaining...
I'm not sure what you mean here exactly. The original assert() can be
function assert(cond, err)
if cond then return cond
else error(err or "assertion failed")
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.