1
我不知道是否有什么办法来优化下面的斯卡拉代码,因为它看起来效率不高。 基本上,我只是想从流中删除任何不是Tweet
的对象,并将它映射到Tweet
而不是Any
。斯卡拉阿卡流合并过滤器和地图
val tweetsFlow = Flow[Any].filter({
case _: Tweet => true
case _ => false
}).map({
case tweet: Tweet => tweet
})