let groupA : Set<Int> = [1111,2000]
let groupB : Set<Int> = [221,122]
let groupC : Set<Int> = [300,12,23,232]
StudentGroups = [groupA, groupB, groupC]
假设我无法访问上面声明的集合,我正在尝试找到一种解决方案来提取StudentGroups中的每个集合,以成为它们自己的新数组。
例如:预计从StudentGroups中提取的数组应为:
groupA = [1111,2000]
groupB = [221,122]
groupC = [300,12,23, 232]
这就是我为了测试自己的进步所做的:
for idx in StudentGroups.indices {
let elem = StudentGroups[idx]
print(elem)
//This will return [1111,2000]
// [221,122]
// [300,12,23,232]
}
目前,它只在集合中迭代。不幸的是,我对如何继续下去一无所知
1条答案
按热度按时间w46czmvw1#
试着这样做:
...a solution to extract out each sets inside StudentGroups to become their new own array...
,试试这个,将集合的数组转换为数组的数组: