【发布时间】:2016-01-23 23:10:12
【问题描述】:
println(List(List(1,2,3)).flatMap(identity))
= 列表(1,2,3)
println(Iterable(List(1,2,3)).flatMap(identity))
同样的结果
println(Option(List(1,2,3)).flatMap(identity))
Error:(8, 39) type mismatch;
found : List[Int] => List[Int]
required: List[Int] => Option[?]
println(Option(List(1,2,3)).flatMap(identity))
^
^
我认为存在 option2iterable 隐式转换,所以 Options 的行为应该与 Iterable 相同?
【问题讨论】:
标签: scala collections