You shall not pass!
When I first read about Swift's
guard statement, I thought it was brilliant. I imagined Beefeater guards standing outside the Towers of London in their impratical scarlet and gold uniforms with their pikes challenging anyone trying to get in.
If you knew the password, or had the right credentials, the Beefeaters let you pass. You were free to enter and go where you pleased. If not, you weren't even allowed inside. End of story.
As @rooster points out in the camel example, the
guard on duty is only checking to see that the
humpCount is less than or equal to 2. If so, the
guard lets the variable into the function to have more fun. Have a nice day, sir. If the
guard sees you're trying to get in with more than 2 humps, he denies your visa. No entry for you!
In the second example, the
guard challenges the variable
strength. Before being allowed to pass the
guard, the variable must prove that it actually has a value and isn't
nil. If the variable is
nil, access denied. There's the exit. Scram.