Skip to content

Instantly share code, notes, and snippets.

@jimmyhoran
Created August 4, 2019 12:17
Show Gist options
  • Save jimmyhoran/4b598e8774b6d81a6cef2bf61cf7d692 to your computer and use it in GitHub Desktop.
Save jimmyhoran/4b598e8774b6d81a6cef2bf61cf7d692 to your computer and use it in GitHub Desktop.
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