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
?