このページの下に示されているスニペットは、メッセージの送信の使用法を示しています。私が理解に苦しむことの 1 つは、judge(Pid, Band, Album) ->
関数呼び出しの receive 句内の 2 番目の引数{Pid, Criticism} -> Criticism
です。
変数の目的は何Criticism
ですか?
スニペットは次のとおりです。
start_critic() ->
spawn(?MODULE, critic, []).
judge(Pid, Band, Album) ->
Pid ! {self(), {Band, Album}},
receive
{Pid, Criticism} -> Criticism
after 2000 ->
timeout
end.
critic() ->
receive
{From, {"Rage Against the Turing Machine", "Unit Testify"}} ->
From ! {self(), "They are great!"};
{From, {"System of a Downtime", "Memoize"}} ->
From ! {self(), "They're not Johnny Crash but they're good."};
{From, {"Johnny Crash", "The Token Ring of Fire"}} ->
From ! {self(), "Simply incredible."};
{From, {_Band, _Album}} ->
From ! {self(), "They are terrible!"}
end,
critic().