On Sat, Jun 05, 2004 at 05:51:44AM +0900, Jean-Hugues ROBERT wrote:
> if DEBUG
>   def assert
>     raise "assertion failure" unless yield
>   end
> else
>   def assert; end
> end
> 
> There is some overhead when not in DEBUG mode, but that
> is the best you can do in Ruby as far as I know.

That's the best I know of that you could do in pure ruby.

If you were to write an extension then, if DEBUG is false you could have
it modify the code in place whenever assert is called.  I doubt the
performance gain would be significant enough to make it worthwhile,
though.

Paul