Swift – Empty String

To create an empty string in Swift, we can create a String literal with nothing in it, or a String type initialiser with no value passed as argument to it.

An example to create an empty String with empty String literal is

var str = ""

An example to create an empty String with empty String type initializer is

ADVERTISEMENT
var str = String()

Conclusion

In this Swift Tutorial, we learned how to create an Empty String in Swift programming.