loading...

How to remove last character from a string in Swift

saigowthamr profile image Sai gowtham Originally published at codeexamples.dev ・1 min read

To remove the last character from a string we need to use the removeLast() method in swift.

Here is an example that removes the last character d from a string.

var str = "Fun World"

str.removeLast()

print(str)

Output:

Fun Worl

Note: The removeLast() method modifies the original string.

Swift version: 5.1

originally published at codeexamples.dev

Discussion

markdown guide