在Erlang中,何时使用;或,或。? [英] In Erlang, when do I use ; or , or .?
问题描述
我一直在尝试学习Erlang,并且在函数和 case
语句的结尾行遇到了一些问题。
I have been trying to learn Erlang and have been running into some problems with ending lines in functions and case
statements.
我何时在函数中使用分号(;
),逗号(,
)或句点或 case
语句?
When do I use a semicolon (;
), comma (,
), or period inside my functions or case
statements?
推荐答案
正常代码行末尾的逗号。 br>
case语句末尾或if语句等的分号。
最后一个case或if语句末尾没有任何内容。
函数末尾的句点。
Comma at the end of a line of normal code.
Semicolon at the end of case statement, or if statement, etc.
The last case or if statement doesn't have anything at the end.
A period at the end of a function.
示例(对不起,随机变量名称不起作用,显然它没有任何作用,但只说明了一点) :
example (sorry for the random variable names, clearly this doesn't do anything, but illustrates a point):
case Something of
ok ->
R = 1, %% comma, end of a line inside a case
T = 2; %% semi colon, end of a case, but not the end of the last
error ->
P = 1, %% comma, end of a line inside a case
M = 2 %% nothing, end of the last case
end. %% period, assuming this is the end of the function, comma if not the end of the function
这篇关于在Erlang中,何时使用;或,或。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!