Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.5.4 非局部返回疑问 #16

Open
franklifeisnow opened this issue Nov 23, 2021 · 2 comments
Open

6.5.4 非局部返回疑问 #16

franklifeisnow opened this issue Nov 23, 2021 · 2 comments

Comments

@franklifeisnow
Copy link

//书中代码如下
fun main() {
    foo { return@foo }
}

fun foo(returning: () -> Unit) {
    println("before local return")
    returning()
    println("after local return")
    return
}
//运行结果
before local return
//我本机运行结果
before local return
after local return

希望有大佬能解疑

@yunzhouhua
Copy link

我也发现了这个问题,编译成字节码看一下,其实还是一个局部返回,不管lambda里面怎么返回,invoke调用结束后还是会继续往下执行。
image

@somafish
Copy link

somafish commented Aug 7, 2022

同问,现在对这个带标签返回理解已经产生偏差了,网上很多博文写来写去感觉都是抄的,有大佬能详细解释一下这个点吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants