As per the definition in apple documentation assert
and precondition
has the following signatures:
assert(_:_:file:line:)
precondition(_:_:file:line:)
But while programming I did not find a way to use file
and line
parameters. Why are they actually used? Though the condition is failed I did not find any file or line number in the console.
The two parameters are defaulted by swift compiler, so you do not need to supply any values for them. In fact, you shouldn't supply them to avoid incorrect reporting.
Below is an example of how a precondition failure is reported:
Note how the file name MyPlayground.playground
and line number 5
are filled in automatically.