Fast replacement for assert(): affirm()

Your example would be just as slow as the original assert to make it like affirm you would do

function Affirm(assertion, ...)
    if assertion == true then return end
    error(string.format(...))
end

Now the message is only formatted if assertion is not true

2 Likes