我有一个列entry
的模型,它是String
。有时候条目中有一些文本,有时它没有,它是一个空字符串。
当我尝试在控制台中打印字符串时,我收到The process has been returned to the state before expression evaluation.
(正在运行e object.entry
)
不确定为什么不只是打印""
尝试e object.entry!
会给我error: operand of postfix '!' should have optional type; type is 'String'
有关如何解决此问题的任何想法?
答案 0 :(得分:0)
空字符串""并不代表零,而entry
不是可选类型
我认为你应该宣布entry
为""初始化对象时
class object {
var entry = ""
//do anything you want next
}