VOOZH about

URL: https://www.geeksforgeeks.org/swift/how-to-append-a-string-to-another-string-in-swift/

⇱ How to Append a String to Another String in Swift? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Append a String to Another String in Swift?

Last Updated : 5 Jul, 2022

Swift language supports different types of generic collections and a string is one of them. A string is a collection of alphabets. In the Swift string, we add a string value to another string. To do this task we use the append() function. This function is used to add a string value to another string. It will return the appended string.

Syntax:

string.append(str: String)

Here string is an object of the String class.

Parameters: This function accepts a parameter that is illustrated below:

  • str: This is a string that will be joined to the string.

Return Value: This function returns an appended string.

Example 1:

Output:

GeeksforGeeks

Example 2:

Output:

GeeksforGeeks is a CS Portal.
Comment
Article Tags:

Explore