-
Are ctx.assert and ctx.throw interchangable so if i have to run multiple side effects in an if-statement i don't need to run assert inside? The docs says assert is "similar to .throw()", and i can see they return the same type. But there could still be other side effects. If so, could the docs be updated with: "assert returns the same as .throw() if the first argument is false". |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Assert only throws an exception if the statement is falsy, while throw always throws an exception on call. These concepts are translated from traditional assert and throw semantics. If you still feel these are unclear, maybe PR a change and people can review it? Subjectively I don't think it's unclear, because I assume the purpose of assert and throw is commonly known, but maybe I'm wrong or misunderstand the issue? |
Beta Was this translation helpful? Give feedback.
Assert only throws an exception if the statement is falsy, while throw always throws an exception on call. These concepts are translated from traditional assert and throw semantics. If you still feel these are unclear, maybe PR a change and people can review it? Subjectively I don't think it's unclear, because I assume the purpose of assert and throw is commonly known, but maybe I'm wrong or misunderstand the issue?