Last active
June 19, 2018 02:34
-
-
Save aainaj/5d65939f16b4236708c4e2fac8e3f222 to your computer and use it in GitHub Desktop.
PreconditionFailure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* syntax: | |
public func preconditionFailure( | |
_ message: @autoclosure () -> String = default, | |
file: StaticString = #file, | |
line: UInt = #line) -> Never | |
*/ | |
func validateAge(age: Int) -> Bool { | |
guard age >= 3 else { | |
preconditionFailure("Age can't be less than 3") | |
} | |
return true | |
} | |
_ = validateAge(age: 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment