TIL: Guard Statements

Guard statements do not complain about fatalError without a return type due to the signature of the method, it returns a value of ‘Never’ that stops execution in it’s tracks.

public func fatalError(_ message: @autoclosure () -> String = default, file: StaticString = #file, line: UInt = #line) -> Never

Swift won’t complain about the following

guard let listItem = dataSource.dataForRow(at: indexPath) else {fatalError("Unable to retrieve data for indexpath \(indexPath)") } 
Up Next:

Experiment with smaller posts

Experiment with smaller posts