What does it mean print(_:separator:terminator:)

There are 2 overloads of print (2 different functions with the same name) – this one and this one.

If you just say print, it is ambiguous which overload you mean. Therefore, you also specify the parameter labels of the functions, so the first overload is called print(_:separator:terminator:) and the second is called print(_:separator:terminator:to:).

Let’s dissect print(_:separator:terminator:). We can see that it has three parameter labels – _, separator and terminator. The : are just there to separate the labels. It is also the character you write after the label when you call the function:

print("hello", "world", separator: " ")

so it kind of makes sense.

Leave a Comment