Can't understand kotlin logic. For sush code
inline fun inlined( block: () -> Unit) {
block()
println("hi!")
}
fun foo() {
inlined {
println("5")
return@inlined // OK: the lambda is inlined
println("5")
}
println("6")
}
fun main() {
foo()
}
Expected such output "56" but got "5hi!6". How could this happen?
And on my understanfing it contradicts following description from documentation

Can someone explain it?
UPDATE: Thanks for your answers. I still wandering why execustion of inlined() proceed after calling return@inlined? Anyway lambda is not aware about "inlined()" paremeter "block" but behaves like return@block was called.
You are not doing a non-local return. You are doing a local return, because you used
@inlined. The local return returns from the lambda, so code execution continues from afterblockwas called inside theinlined()function. The next line isprintln("hi!"). Theninlined()returns and code continues execution inside thefoo()function.If you did a non-local return by calling
returninstead ofreturn@inlined, then the only thing you would see in the console is5. Theprintln("6")code would never be reached since you would be directly returning fromfoo().