Erlang-logical-operators
提供:Dev Guides
アーラン-論理演算子
Erlangで使用できる論理演算子は次のとおりです。
Operator | Description | Example |
---|---|---|
or | This is the logical “and” operator | true or true will give true |
and | This is the logical “or” operator | True and false will give false |
not | This is the logical “not” operator | not false will give true |
xor | This is the logical exclusive “xor” operator | True xor false will give true |
次のコードスニペットは、さまざまな演算子の使用方法を示しています。
例
-module(helloworld).
-export([start/0]).
start() ->
io:fwrite("~w~n",[true or false]),
io:fwrite("~w~n",[true and false]),
io:fwrite("~w~n",[true xor false]),
io:fwrite("~w~n",[not false]).
上記のプログラムの出力は次のようになります-
出力
true
false
true
true