0

我试图在案例中使用“_”,但我错过了一些东西。我正在做的是:

case (Packet =:= #xmlel{name = <<"message">>, attrs = [_, {<<"type">>,<<"chat">>}], children = _}) of
    true ->
        ?INFO_MSG("True ###### Packet ~p", [Packet]);
    _ ->
        ?INFO_MSG("False ###### Packet ~p", [Packet])
end,

错误是:变量'_'未绑定。

我希望这个变量“_”在这个函数中意味着每一件事。

喜欢 -->

attrs = [Whatever, {<<"type">>,<<"chat">>}]

children = Whatever

我该怎么做?谢谢。

4

1 回答 1

2

问题是:

你不能在 '=' 的右边使用 '_'

你只能把它放在'='的左边

例如

{_,4} = {x,y}(正确的)

{x,y} = {_,4}(错误的)

于 2016-03-02T02:57:54.143 回答