Laxmikant Ratnaparkhi
Laxmikant Ratnaparkhi

Reputation: 4993

Skip else condition in case statement erlang

I have a list of list (AllData) over which I'm iterating, to get some elements depending on sepc-documentation conditions. Keeping empty tuple {} or only ok is causing issues to my list and really I don't want to insert anything to my NewList in else(_->) block of inner case statement.

Can we skip the else ( _-> ) condition?

Here is my sample code:

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).

Upvotes: 0

Views: 432

Answers (1)

legoscia
legoscia

Reputation: 41528

Just return Counter and NewList unchanged:

{Counter, NewList }

Upvotes: 2

Related Questions