1
我Example
类型具有以下元素的列表:斯卡拉:获取列表的元素与两个限制
Example("One", "1", null)
Example("Two", "1", null)
Example("Three", "2", someObject)
Example("Four", "3", someObject)
Example("Five", "3", null)
Example("Six", "3", someObject)
Example("Seven", "4", someObject)
我想是在第三场null
和"3"
的第一个元素第二场。
在这个特定的情况下,它将是第一个字段中的"Five"
的条目。
我该怎么做?什么是最好的功能方法呢?
正是我想要的。谢谢。 –
'find'或'collectFirst'在这种情况下会更有效率。 – Aivean