print() vs debugPrint() in swift

Rajan Twanabashu picture Rajan Twanabashu · Jan 24, 2017 · Viewed 24.8k times · Source

This might be a simple question but because of clear understanding between print() and debug() print in swift I am unable to understand where to use each one.

Answer

Iggy picture Iggy · Apr 8, 2017

You use debugPrint when you want more information about what is being printed to the console. The additional information is usually useful for debugging.

print() - Writes the textual representations of the given items into the standard output.

debugPrint() - Writes the textual representations of the given items most suitable for debugging into the standard output.

Basically debugPrint adds additional information that is useful for debugging like type information etc.

An example:

print(1...5)
// Prints "1...5"


debugPrint(1...5)
// Prints "CountableClosedRange(1...5)"