Created
August 4, 2019 12:17
-
-
Save jimmyhoran/4b598e8774b6d81a6cef2bf61cf7d692 to your computer and use it in GitHub Desktop.
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
import Foundation | |
enum Debug { | |
static func print(_ item: @autoclosure () -> Any, separator: String = " ", terminator: String = "\n") { | |
#if DEBUG | |
Swift.print(item(), separator: separator, terminator: terminator) | |
#endif | |
} | |
} | |
// MARK: Example | |
func helloWorld() -> String { | |
return "Hello 🌏" | |
} | |
Debug.print(helloWorld()) | |
Debug.print("Hello 🇦🇺") | |
// MARK: Alternative | |
func print(_ item: @autoclosure () -> Any, separator: String = " ", terminator: String = "\n") { | |
#if DEBUG | |
Swift.print(item(), separator: separator, terminator: terminator) | |
#endif | |
} | |
print("Only print in DEBUG mode") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment