Created
August 25, 2016 03:22
-
-
Save cfilipov/bf28d4071efc1f6abac43736a68cb099 to your computer and use it in GitHub Desktop.
Undefined Func in Swift
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
/// | |
/// From: https://realm.io/news/swift-summit-johannes-weiss-the-type-system-is-your-friend/ | |
/// | |
/// Slightly improved: | |
/// * Report function, file and line of actual call site | |
/// * Warn usage of this function (somewhat hacky though) | |
/// * Discardable result | |
@available(*, deprecated, message: "Use of undefined()") | |
@discardableResult public func undefined<T>( | |
_ message: StaticString = "" | |
, function: StaticString = #function | |
, file: StaticString = #file | |
, line: UInt = #line) | |
-> T { | |
fatalError( | |
"undefined(\(message)) in \(function)", | |
file: file, | |
line : line) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment