0 votes
in Swift by
What is a GUARD statement? What is the benefit of using the GUARD statement in swift?

1 Answer

0 votes
by
A GUARD statement is used to transfer the program control out of the scope when one or more conditions are not met. Using this statement helps in avoiding the pyramid of doom.

A GUARD statement will be in the following form:

guard condition else

{

Statements

}
...