franztesca
10/10/2023, 8:51 PMYoussef Shoaib [MOD]
10/10/2023, 8:58 PMfun main() {
var myList: List<suspend (Int) -> Int>
myList = listOf(suspend { n: Int -> n })
myList = listOf(suspend { n: Int -> n})
myList = listOf(suspend { it })
//myList = listOf({ n: Int -> n })
myList = listOf({ n -> n })
myList = listOf({ it })
}
fun <T, R> suspend(block: suspend (T) -> R) = block
except that this convention is deprecated now, probably for the better, and so instead you can surround the lambda in parens, or better just rename that fun suspend to suspendLambda or somethingephemient
10/10/2023, 9:21 PMfranztesca
10/10/2023, 9:56 PM// Explicit type -> doesn't work
myList = listOf({ n: Int -> n })
// Implicit type -> works
myList = listOf({ n -> n })
🤔