Created
October 3, 2014 06:36
-
-
Save jesusdomin/a5588cfbcaa9c815459d to your computer and use it in GitHub Desktop.
Asserts in swift
This file contains hidden or 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
// More Info: https://developer.apple.com/swift/blog/?id=15 | |
func assert(condition: @autoclosure () -> Bool, _ message: String = "", file: String = __FILE__, line: Int = __LINE__) { | |
#if DEBUG | |
if !condition() { | |
println("assertion failed at \(file):\(line): \(message)") | |
abort() | |
} | |
#endif | |
} | |
func logAndAssert(condition: @autoclosure () -> Bool, _ message: StaticString = "", file: StaticString = __FILE__, line: UWord = __LINE__) { | |
logMessage(message) | |
assert(condition, message, file: file, line: line) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment