我有一個Seq[Object]
,我想遍歷每個對象,並檢查其布爾屬性之一是否是真/假。我試着使用flatmap
其次是filter
,但它不工作:斯卡拉,如何遍歷序列
val systemResourcesExpandable = host.systemResources flatMap (.child) filter { childseq =>
for {
child <- childseq;
child.config flatMap (.cpuAllocation) flatMap (_.expandableReservation)
} yield { child }
}
你能發佈你的代碼片段,並解釋什麼是不工作? – Ren