pavi2410
03/13/2021, 6:28 PMfn factorial(n: u32) -> u32 {
if dbg!(n <= 1) {
dbg!(1)
} else {
dbg!(n * factorial(n - 1))
}
}
I hope to be able to write something like this in Kotlin
fun factorial(n: Int): Int {
if (dbg(n <= 1)) {
return dbg(1)
} else {
return dbg(n * factorial (n - 1))
}
}
Possible incomplete implementation
fun <T> dbg(expr: T): T {
println(expr)
return expr
}
Is there any way to capture the expression syntax itself rather than the value?pavi2410
03/13/2021, 6:30 PMpavi2410
03/13/2021, 6:48 PMDominaezzz
03/13/2021, 7:07 PMYoussef Shoaib [MOD]
03/13/2021, 7:33 PMcom.bnorm.power.kotlin-power-assert
: https://github.com/bnorm/kotlin-power-assertitnoles
03/13/2021, 9:28 PMchristophsturm
03/14/2021, 8:12 PM