Sourabh Rawat
02/10/2021, 12:35 PMResult<T>
from Java code? My interface returns Result<T>
. i am seeing Object
instead of Result<T>
😕Vampire
02/10/2021, 12:51 PMYoussef Shoaib [MOD]
02/10/2021, 1:04 PMResult<T>
is an inline class that uses a backing field of Any?
which, on the JVM, translates to Object
. Can you possibly provide your usecase? Because the simplest way to approach this would be to consider any Object
that you get to be a failure if it is instanceof Throwable
and otherwise it is success.Sourabh Rawat
02/11/2021, 3:49 AMinterface PropSource {
fun <T> getProperty(key: String): Result<T>
fun getAllProperties(): Result<Map<String, Any>>
}
i have this interface. I am using Result<T>
here so that I can encapsulate failure in the return object.