On your example, you need to have a function that treat the declared result :
fun getResult() : List<String>|Throwable = TODO()
fun handleResult(foo: List<String>|Throwable) = TODO()
handleResult(getResult())
until you check the type
fun getResult() : List<String>|Throwable = TODO()
fun handleResult(foo: List<String>) = TODO()
fun handleResult(foo: Throwable) = TODO()
val x = getResult()
if (x !is Throwable) {
handleResult(x) // call handleResult(foo: List<String>)
}
But the strength of union type adopt by typescript, ceylon and the next scala version, is for types (like examples show in precedent comments)
// Let be properties type be a map of key string and value (not simple object)
val propreties : Map<String, String|LocalDate|Number>
Others examples with json type.