English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang Relational Operators

Operators in Erlang

The following are the relational operators available in Erlang.

Operator Description Example
== Test if two objects are equal 2 = 2 The result is true
/= Test if two objects are not equal 3 /= 2 The result is true
< Test if the left object is less than the right operand 2 < 3 The result is true
<=Test if the left object is less than or equal to the right operand 2 <=3 The result is true
>Test if the left object is greater than the right operand 3 > 2 The result is true
>=Test if the left object is greater than or equal to the right operand 3 >= 2 The result is true

The following code segment shows how to use various operators.

Online Example

-module(helloworld). 
-export([start/0]). 
start() -> 
   io:fwrite("~w~n",[3==2]), 
   io:fwrite("~w~n",[3/=2]), 
   io:fwrite("~w~n",[3<2]), 
   io:fwrite("~w~n",[3<=2]), 
   io:fwrite("~w~n",[3>2]), 
   io:fwrite("~w~n",[3>=2]).

The output of the above program will be:

false
true
false
false
true
true

Operators in Erlang