gpt4 book ai didi

swift - String() 和 ""之间的区别

转载 作者:行者123 更新时间:2023-11-30 13:05:44 25 4
gpt4 key购买 nike

基本上 String() 之间有什么区别和""

var x = "Test"
x = String()
x = ""

上面这两行有什么区别吗?

最佳答案

根据Apple documentation ,字符串是等效的:

Initializing an Empty String

To create an empty String value as the starting point for building a longer string, either assign an empty string literal to a variable, or initialize a new String instance with initializer syntax:

var emptyString = ""               // empty string literal
var anotherEmptyString = String() // initializer syntax

关于swift - String() 和 ""之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39401356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com