Paul Woitaschek
06/27/2019, 8:17 AMas
and when do you use the prefix to
?ribesg
06/27/2019, 8:19 AMas
would be some kind of cast while to
would be a transformationmarstran
06/27/2019, 8:20 AMto
if the function transforms something to another type (like putting all elements of a sequence into a list). Use as
if it will only provide a view over the original object (like a sequence over the original list).ribesg
06/27/2019, 8:20 AMto
basically costs more than as
. It’s more complex.Toddobryan
06/27/2019, 8:20 AMas
implies that the conversion could be implicit (like when Java upcasts an int
to a double
, because there's no chance of losing information), but to
implies that you're having to do some fiddling to get it to work and it could conceivably go wrong.Paul Woitaschek
06/27/2019, 8:23 AMFlowable.asFlow()
should rather be called Flowable.toFlow()
?Paul Woitaschek
06/27/2019, 8:24 AMPaul Woitaschek
06/27/2019, 8:24 AMIf the returned value is a view of what created is, we useas
Paul Woitaschek
06/27/2019, 8:24 AMFile.toRequestBody()
-> File.asRequestBody()
gildor
06/27/2019, 8:31 AMSo you think for exampleNope, because under the hood it’s still Flowable, so it should beshould rather be calledFlowable.asFlow()
Flowable.toFlow()
as
gildor
06/27/2019, 8:33 AMgildor
06/27/2019, 8:34 AMYeah there’s also the idea thatMostly becausebasically costs more thanto
as
as
usually does not copying, but it’s not a rule, it’s more like consequencePaul Woitaschek
06/27/2019, 8:35 AM