什么是开始...结束在Erlang用于? [英] What is begin...end in Erlang used for?

查看:106
本文介绍了什么是开始...结束在Erlang用于?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在Erlang的文档中( begin ... end .html#id79819rel =nofollow noreferrer> here ),但它没有给出一些如何有用的例子。

I just stomped at a begin...end in Erlang's documentation (here), but it doesn't give some examples of how it is useful.

在StackOverflow中我发现两种情况,人们将使用 begin ... end ,无论是在列表推导中:

Looking here in StackOverflow I found two cases where people would be using begin...end, both in list comprehensions:

  • https://stackoverflow.com/a/5645116/979505
  • https://stackoverflow.com/a/5141263/979505

但是我想知道是否有更多的这种用途。

But I wonder if there are more of such uses.

任何人都可以提供另一种场景, code> begin ... end 在Erlang中有用吗?

Can anyone provide another scenario in which a begin...end is useful in Erlang?

谢谢

推荐答案

宏,例如:

-define(M(A, B),
    begin
        C = foo(),
        bar(A, B, C)
    end).

这篇关于什么是开始...结束在Erlang用于?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆