The append(_:)
method is used to append a string or character to another string.
// append string
string.append(str)
// append character
string.append(char)
string
: This is the string we want to append to another string or character.
str
: This is another string we want to append to the original string
.
char
: This is the character we want to append to string
.
This method returns a new string containing the original string together with the appended string or character.
// create stringsvar str1 = "Edpre"var str2 = ""var str3 = "awe"var str4 = ""// append strings and charactersstr1.append("sso")str2.append("is")str3.append("some")str4.append("!")// print resultsprint(str1)print(str2)print(str3)print(str4)
append(_:)
method.