Swift Hello World

In the programming language, displaying results and messages plays an important role. Because there is no benefit of the program without generating any result. When learning a programming language it is very important how we display the result and the message. Some method is used for this task in programming language. Let us know what are these methods in Swift language.

print(_:separator:terminator:)

The print method performs the task smoothly. This method can be done using various parameters. This first criterion indicates the user's message. It can be the form of an integer and a string. The second 2 criteria are helpful in organizing the message.

Separator : This can be used to ensure the difference between the results of the given criteria. By default there is a blank space between parameters. We can change this according to the need.

Terminator : This indicates the end of the result. The line terminator character is used by default. We can also change it according to our need.

Let's understand it with some examples.

// One parameter with user message
print("Hello World")

// Two parameter with user message
print("Hello","Programer")

// Use separator
print("Hello","new","Programer",separator:"⚘")

// Use separator and terminator
print("Hello","new","Programer",separator:"⚘",terminator:"❆")

// User message
print("Hello everyone")

Output:

Hello World
Hello Programer
Hello⚘new⚘Programer
Hello⚘new⚘Programer❆Hello everyone


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved