Swift – Print to Console

To print an output to console in Swift, use print() function. print() function writes the textual representations of the given items into the standard output, which in this case is console

Examples

In the following example, we print a string to console output.

main.swift

print("Hello World")

Output

We can pass multiple values to print() function as arguments for printing to console output.

main.swift

print("apple", "banana", "cherry")

Output

Conclusion

In this Swift Tutorial, we learned how to print output to console using print() function, with the help of examples.