【发布时间】:2018-12-10 15:07:58
【问题描述】:
我有一个列表 (AllData),我正在对其进行迭代,以根据 sepc 文档条件获取一些元素。保持空元组{} 或仅ok 会导致我的列表出现问题,实际上我不想在内部case 语句的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).
【问题讨论】:
标签: erlang