Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Guard (computer science)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Concept in computer science}} In [[computer programming]], a '''guard''' is a [[Boolean expression]] that must evaluate to true if the [[Execution (computing)|execution]] of the [[Computer program|program]] is to continue in the branch in question. Regardless of which [[programming language]] is used, a '''guard clause''', '''guard code''', or '''guard statement''' is a check of integrity [[precondition]]s used to avoid errors during execution. The term '''guard clause''' is a [[Software design pattern]] attributed to [[Kent Beck]] who codified many often unnamed coding practices into named software design patterns, the practice of using this technique dates back to at least the early 1960's. The '''guard clause''' most commonly is added at the beginning of a procedure and is said to "guard" the rest of the procedure by handling edgecases upfront.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)