What is a non-local return?

前端 未结 3 2007
滥情空心
滥情空心 2021-02-19 10:53

What is non local return? In what scenarios it is useful? Please give an example to explain.

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 11:50

    Here's a good article on the use of non local returns in the context of ruby blocks.

    Ruby’s blocks support non-local-return (some references), which means that a return from the block behaves identically to returning from the block’s original context.

    It basically mean that you can call a block from a function, and the block has the ability to return from the original function.

提交回复
热议问题