English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Conditional Statements in Erlang
Sometimes, it is necessary to nest multiple if statements within each other, which is possible in other programming languages. In Erlang, this is also possible.
The following diagram is a graphical representation of nested if statements.
The following program shows an example:
-module(helloworld). -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.
The following points should be noted in the above program-
when the firstifThe value of the condition istrueThen the evaluation of the second if condition begins.
The output of the above code will be-
A is less than 5