Marc Knaup
10/22/2017, 10:34 AMfunc someFunction(callback: () throws -> Void) rethrows {
try callback()
}
If callback is marked throws then someFunction is also marked throws, otherwise it’s not.
That would allow for nice reusable code like this:
inline suspend? fun <T, R> Iterable<T>.map(transform: suspend? (T) -> R): List<R> { // syntax TBD - maybe doesn't even need special syntax
val transformedElements = mutableListOf<R>()
for (element in this)
transformedElements += transform(element) // either suspend or not
return transformedElements
}
If transform is suspendable then the whole function is suspendable, otherwise it’s not.