Functions
The following functions are available globally.
-
Performs a traditional C-style assert with an
Error.Declaration
Swift
@inlinable public func assert(_ condition: @autoclosure () -> Bool, error: Error, file: StaticString = #file, line: UInt = #line)Parameters
conditionThe condition to test.
conditionis only evaluated in playgrounds and-Ononebuilds.errorThe error that represents the assertion failure when
conditionevaluates tofalse.fileThe file name to print with the description of
errorif the assertion fails. The default is the file whereassert(_:error:file:line:)is called.lineThe line number to print along with the description of
errorif the assertion fails. The default is the line number whereassert(_:error:file:line:)is called. -
Performs a traditional C-style assert with an optional message.
Declaration
Swift
@inlinable public func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)Parameters
conditionThe condition to test.
conditionis only evaluated in playgrounds and-Ononebuilds.messageA string to print if
conditionis evaluated tofalse. The default is an empty string.fileThe file name to print with
messageif the assertion fails. The default is the file whereassert(_:_:file:line:)is called.lineThe line number to print along with message if the assertion fails. The default is the line number where
assert(_:_:file:line:)is called. -
Indicates that an internal sanity check failed.
Declaration
Swift
@inlinable public func assertionFailure(error: Error, file: StaticString = #file, line: UInt = #line)Parameters
errorThe error that represents the assertion failure.
fileThe file name to print with the description of
error. The default is the file whereassertionFailure(error:file:line:)is called.lineThe line number to print along with the description of
error. The default is the line number whereassertionFailure(error:file:line:)is called. -
Indicates that an internal sanity check failed.
Declaration
Swift
@inlinable public func assertionFailure(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)Parameters
messageA string to print in a playground or
-Ononebuild. The default is an empty string.fileThe file name to print with
message. The default is the file whereassertionFailure(_:file:line:)is called.lineThe line number to print along with
message. The default is the line number whereassertionFailure(_:file:line:)is called. -
Unconditionally reports a given error and stops execution.
Declaration
Swift
@inlinable public func fatalError(_ error: Error, file: StaticString = #file, line: UInt = #line) -> NeverParameters
errorThe error to report.
fileThe file name to print with the description of
error. The default is the file wherefatalError(_:file:line:)is called.lineThe line number to print with the description of
error. The default is the line number wherefatalError(_:file:line:)is called. -
Unconditionally prints a given message and stops execution.
Declaration
Swift
@inlinable public func fatalError(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) -> NeverParameters
messageThe string to print. The default is an empty string.
fileThe file name to print with
message. The default is the file wherefatalError(_:file:line:)is called.lineThe line number to print along with
message. The default is the line number wherefatalError(_:file:line:)is called. -
Checks a necessary condition for making forward progress.
Declaration
Swift
@inlinable public func precondition(_ condition: @autoclosure () -> Bool, error: Error, file: StaticString = #file, line: UInt = #line)Parameters
conditionThe condition to test.
condition is not evaluated in-Ounchecked` builds.errorThe error that represents the precondition failure when
conditionevaluates tofalse.fileThe file name to print with the description of
errorif the precondition fails. The default is the file whereprecondition(_:error:file:line:)is called.lineThe line number to print along with the description of
errorif the precondition fails. The default is the line number whereprecondition(_:error:file:line:)is called. -
Checks a necessary condition for making forward progress.
Declaration
Swift
@inlinable public func precondition(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line)Parameters
conditionThe condition to test.
conditionis not evaluated in-Ouncheckedbuilds.messageA string to print if
conditionis evaluated tofalsein a playground or-Ononebuild. The default is an empty string.fileThe file name to print with
messageif the precondition fails. The default is the file whereprecondition(_:_:file:line:)is called.lineThe line number to print along with
messageif the precondition fails. The default is the line number whereprecondition(_:_:file:line:)is called. -
Indicates that a precondition was violated.
Declaration
Swift
@inlinable public func preconditionFailure(error: Error, file: StaticString = #file, line: UInt = #line) -> NeverParameters
errorThe error that represents the precondition failure.
fileThe file name to print with the description of
error. The default is the file wherepreconditionFailure(error:file:line:)is called.lineThe line number to print along with the description of
error. The default is the line number wherepreconditionFailure(error:file:line:)is called. -
Indicates that a precondition was violated.
Declaration
Swift
@inlinable public func preconditionFailure(_ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) -> NeverParameters
messageA string to print in a playground or
-Ononebuild. The default is an empty string.fileThe file name to print with
message. The default is the file wherepreconditionFailure(_:file:line:)is called.lineThe line number to print along with
message. The default is the line number wherepreconditionFailure(_:file:line:)is called.
View on GitHub
Functions Reference