LeoColman
11/07/2019, 3:35 PMRuckus
11/07/2019, 3:40 PMLeoColman
11/07/2019, 3:40 PMLeoColman
11/07/2019, 3:40 PMCasey Brooks
11/07/2019, 3:42 PMAny()
is what you want?LeoColman
11/07/2019, 3:44 PMSequence<T>
. Inside the DSL, the values of T
may share a common type Y
. I want to return Sequence<Y>
if they do, and Sequence<Any>
if they don'tLeoColman
11/07/2019, 3:45 PMclass Y
class A : Y
class B : Y
buildSequence<Y> {
creatingValue<A> { A() }
creatingValue<B> { B() }
}
LeoColman
11/07/2019, 3:45 PMbuildSequence<Y>
, just buildSequence { }
which would return Sequence<Y>
LeoColman
11/07/2019, 3:47 PMSequence<Any>
is enoughCasey Brooks
11/07/2019, 3:47 PMLeoColman
11/07/2019, 3:47 PMLeoColman
11/07/2019, 3:47 PMbuildSequence<Any>
if the user wants itstreetsofboston
11/07/2019, 4:09 PM@BuilderInference
streetsofboston
11/07/2019, 4:11 PMpublic fun <T> flow(@BuilderInference block: suspend FlowCollector<T>.() -> Unit): Flow<T> = SafeFlow(block)
Just by calling emit(instancOfMyType)
in the provided lambda (argument to block
), the compiler can infer that T
is MyType
LeoColman
11/07/2019, 4:14 PMLeoColman
11/07/2019, 4:14 PMstreetsofboston
11/07/2019, 4:14 PMLeoColman
11/07/2019, 4:16 PMLeoColman
11/07/2019, 4:30 PM@Experimental
without requiring the compiler flag for the client to use?streetsofboston
11/07/2019, 4:32 PMLeoColman
11/07/2019, 5:09 PMLeoColman
11/07/2019, 5:10 PMLeoColman
11/07/2019, 5:14 PMLeoColman
11/07/2019, 5:15 PM