这段代码:
1 until 3 flatMap (x => x + 1)
在工作表中导致此错误:
Multiple markers at this line
- type mismatch; found : Int(1) required: String
- type mismatch; found : Int(1) required: String
- type mismatch; found : x.type (with underlying type Int) required: ?{def +(x$1: ? >: Int(1)): ?} Note that implicit conversions are not applicable because they are ambiguous: both method int2long in object Int of type (x: Int)Long and method int2float in object Int of type (x: Int)Float are possible conversion functions from x.type to ?{def +(x$1: ? >: Int(1)): ?}
- type mismatch; found : x.type (with underlying type Int) required: ?{def +(x$1: ? >: Int(1)): ?} Note that implicit conversions are not applicable because they are ambiguous: both method int2long in object Int of type (x: Int)Long and method int2float in object Int of type (x: Int)Float are possible conversion functions from x.type to ?{def +(x$1: ? >: Int(1)): ?}
此代码按预期运行:1 until 3 flatMap (x => x + 1)
所有适用的集合都map
应该适用于flatMap
吗?