Skip to content

Difference between requires and if..guard ? #21

Answered by alwayscommit
TilakMaddy asked this question in Q&A
Discussion options

You must be logged in to vote

"require" terminates further processing if the condition is not met, cleaner and stricter way to implement conditions that must be true and abort the transaction in case the condition isn't met.

failure of the "if" condition does not terminate the processing unless explicitly mentioned in the if or the else block depending on the logic, and it allows further execution of the program.

might be a good practice to implement validation checks using "require" and logical flow using "if"

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@PatrickAlphaC
Comment options

Answer selected by PatrickAlphaC
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants