有时,需要相互之间嵌入多个 if 语句,这在其他编程语言中也是可能的。在Erlang中,这也是可能的。
-module(helloLearnfk). -export([start/0]). start() -> A=4, B=6, if A < B -> if A > 5 -> io:fwrite("A is greater than 5"); true -> io:fwrite("A is less than 5") end; true -> io:fwrite("A is greater than B") end.
上面的代码输出将是-
链接:https://www.learnfk.comhttps://www.learnfk.com/erlang/erlang-nested-if-statements.html
来源:LearnFk无涯教程网
A is less than 5
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)