我有以下Erlang代码,当我尝试编译它时,会出现以下警告,但这是有道理的。该函数需要两个参数,但我需要匹配“其他所有东西”,而不是x、y或z。
-module(crop).
-export([fall_velocity/2]).
fall_velocity(P, D) when D >= 0 ->
case P of
x -> math:sqrt(2 * 9.8 * D);
y -> math:sqrt(2 * 1.6 * D);
z -> math:sqrt(2 * 3.71 * D);
(_)-> io:format("no match:~p~n")
end.
crop.erl:9: Warning: wrong number of arguments in format call.
我尝试在io:format之后使用匿名变量,但仍然不行。