william
09/28/2020, 12:44 PMactual
value in an expect class
which references a value not given yet? for example I want to achieve
val incoming: ReceiveChannel<Frame>
val incomingText: Flow<String> = incoming.consumeAsFlow().filter { it is Frame.Text }.map { (it as Frame.Text).payload }
where incomingText
is basically a convenience method to give to consumers of that class. the error here states Expected property cannot have an initializer
incomingText
as an extension function but that seems weirdflosch
09/28/2020, 12:52 PMwilliam
09/28/2020, 12:54 PMJoffrey
09/29/2020, 11:58 AMget()
work here?
val incoming: ReceiveChannel<Frame>
val incomingText: Flow<String>
get() = incoming.consumeAsFlow().filter { it is Frame.Text }.map { (it as Frame.Text).payload }
filterIsInstance<Frame.Text>()
:
val incomingText: Flow<String>
get() = incoming.consumeAsFlow()
.filterIsInstance<Frame.Text>()
.map { it.payload }
william
09/29/2020, 12:01 PMflosch
09/29/2020, 12:02 PMwilliam
09/29/2020, 12:02 PMJoffrey
09/29/2020, 12:03 PMwilliam
09/29/2020, 12:03 PMJoffrey
09/29/2020, 12:06 PMexpect/actual
mechanism is about implementing the core of the logic on each platform, it is sort of by definition that the rest (common code) is just “convenience”.william
09/29/2020, 12:08 PM