Checks a necessary condition for making forward progress.
func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)
The condition to test.
conditionis not evaluated in
A string to print if
conditionis evaluated to
falsein a playground or
-Ononebuild. The default is an empty string.
The file name to print with
messageif the precondition fails. The default is the file where
The line number to print along with
messageif the assertion fails. The default is the line number where
Use this function to detect conditions that must prevent the program from proceeding, even in shipping code.
In playgrounds and
-Ononebuilds (the default for Xcode’s Debug configuration): If
false, stop program execution in a debuggable state after printing
-Obuilds (the default for Xcode’s Release configuration): If
false, stop program execution.
conditionis not evaluated, but the optimizer may assume that it always evaluates to
true. Failure to satisfy that assumption is a serious programming error.