![]() |
VOOZH | about |
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 will insert a new character value into the string. To do this task we use the insert() function. This function is used to insert a new character value into the string. It will return a string by inserting a given char into the string.
Syntax:
string.insert(char: Character, at: string.index)
Here string is an object of the String class.
Parameters: This function accepts two parameters that are illustrated below:
Return Value: This function returns a string by inserting a given character into the string.
Example 1:
Output:
GFG
Example 2:
Output:
GFG
Example 3:
Output:
GeeksforGeeks