Erlang-relational-operators
提供:Dev Guides
アーラン-関係演算子
Erlangで使用できる関係演算子は次のとおりです。
| Operator | Description | Example |
|---|---|---|
| == | Tests the equality between two objects | 2 = 2 will give true |
| /= | Tests the difference between two objects | 3/= 2 will give true |
| < | Checks to see if the left object is less than the right operand. | 2 < 3 will give true |
| =< | Checks to see if the left object is less than or equal to the right operand. | 2 =<3 will give true |
| > | Checks to see if the left object is greater than the right operand. | 3 > 2 will give true |
| >= | Checks to see if the left object is greater than or equal to the right operand. | 3 >= 2 will give true |
次のコードスニペットは、さまざまな演算子の使用方法を示しています。
例
-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]).
上記のプログラムの出力は次のようになります-
出力
false
true
false
false
true
true