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
?