Swift – Print without New Line

To print to console output without a new line as trailing character using print() statement, pass empty string for the parameter terminator.

Quick example to print without new line is

print("some string", terminator: "")

Examples

In the following example, we print some string values to console using print() statement without printing the new line as end character.

main.swift

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

Output

applebananacherry

Conclusion

In this Swift Tutorial, we learned how to print to console output without a new line using print() statement, with the help of examples.