结构未填充 [英] Struct not being populated
本文介绍了结构未填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为 Item
的结构,希望填充其变量。
I have a struct called Item
and wish to populate its variables.
struct Item {
var title: String
var others: [String]
}
程序
是所有 Item
创建的数组。
var Programs = [Item]()
我通过以下方式创建了一个结构 Item
:
I created a struct Item
by the following:
var entered = Item(title: hello1, others: ["hello2"])
问题是当我去打印 Items
的列表时,程序数组为空
The problem is that when I go to print the list of Items
, the programs array is empty
print(Programs)
推荐答案
您需要追加它
print("Before :",programs)
let entered = Item(title: hello1, others: ["hello2"])
programs.append(entered)
print("After:",programs)
这篇关于结构未填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文