我有一个列表(AllData
),我正在迭代,根据sepc文档条件获取一些元素。保持空元组{}
或仅ok
会导致我的列表出现问题,而且我不想在内部案例语句的else(_->
)块中向我的NewList插入任何内容。
我们可以跳过else(_->)条件吗?
以下是我的示例代码:
lists:foldl(fun(X , {Counter, NewList}) ->
case X:number() of
{Aa, Bb} ->
case X:id() == Aa of
true ->
//Aa matched
{Counter+1, [X:items()|NewList] }
_->
%% I want to skip the code that goes here in inner case statement.
%% Doing anything here showing a wrong output.
%% Keeping empty tuple with counter changing my output like
{Counter+1, [[]|NewList] }
%% I don't have to do anything here at all.
end;
_->
%% Execute some other code and append to J
{Counter+1, [X:items()|NewList] }
end
end,{0, []}, AllData).
答案 0 :(得分:3)
只需返回Counter
和NewList
:
{Counter, NewList }