df
12/31/2020, 2:05 PMprivate suspend fun upsertAssets(code: String, assets: List<CreateAssetCommand>): List<UpsertAssetResponse> {
return assets.chunked(100)
.map { akeneoClient.upsertAssets(code, it) }
.fold(mutableListOf()) { acc, next -> acc + next }
}
that produces the compile time error Type mismatch: inferred type is List<UpsertAssetResponse> but MutableList<UpsertAssetResponse> was expected
(the fold line). What am I missing?Dominaezzz
12/31/2020, 2:08 PM+
doesn't do what you think it does.todd.ginsberg
12/31/2020, 2:12 PMflatten()
.df
12/31/2020, 2:12 PMdf
12/31/2020, 2:13 PMtodd.ginsberg
12/31/2020, 2:15 PM+
, you get back a List<T>
, not a MutableList<T>
. Since your fold would be recreating the lists anyway, if you seed it with listOf()
instead of mutableListOf()
, that would work.todd.ginsberg
12/31/2020, 2:15 PMflatten
does for you!) 🙂df
12/31/2020, 2:19 PMdf
12/31/2020, 2:19 PMJoel
12/31/2020, 5:38 PMs/map/flatMap
-> profittodd.ginsberg
12/31/2020, 7:35 PMflatMap
over map
+ flatten
. Must have not had enough coffee. 😄