asad.awadia
03/16/2023, 12:20 AMFlow<T> -> U
in a hashmap ? (As the value - key can be string/int)bezrukov
03/16/2023, 10:16 AMval map = HashMap<String, (Flow<Int>) -> Unit>()
and then
map["test"] = { flow -> Unit }
asad.awadia
03/16/2023, 12:59 PMKevin Worth
03/16/2023, 3:01 PMval map = HashMap<String, (Flow<Any>) -> Unit>()
asad.awadia
03/16/2023, 3:05 PMKevin Worth
03/16/2023, 4:03 PMout
keyword? I’m not super strong with it, but perhaps it could help… https://kotlinlang.org/docs/generics.html#declaration-site-variance (may need to scroll up as the docs just above that have quite a bit of context/introduction)asad.awadia
03/16/2023, 4:11 PMbezrukov
03/16/2023, 5:52 PMT
(it's not a flow problem, you can't also declare a val property: T
). It's impossible to parametrize a property, usually you parametrize either class or function. If you did that - you will be able to just declare it with T
(and U
instead of Unit).
Otherwise you have to write val map = HashMap<String, (Flow<Any>) -> Any>()
as mentioned above and do an unchecked castasad.awadia
03/16/2023, 10:59 PM