<div dir="ltr"><div style>I want to delete an item from a list and I've written this fun.</div><div><br></div><div><br></div><div>delete_key_from_list(Key, StatusList)-><br></div><div><div> lists:foldr(</div><div>
fun(Key, Acc) -></div><div><span class="" style="white-space:pre"> </span> Acc;</div><div><span class="" style="white-space:pre"> </span> (Another, Acc) -></div><div><span class="" style="white-space:pre"> </span> [Another|Acc]</div>
<div> end,</div><div> [],</div><div> StatusList).</div></div><div><br></div><div>src/file.erl:172: Warning: variable 'Key' is unused<br></div><div><div>src/file.erl:174: Warning: variable 'Key' is unused</div>
<div>src/file.erl:174: Warning: variable 'Key' shadowed in 'fun'</div></div><div><div>src/file.erl:176: Warning: this clause cannot match because a previous clause at line 174 always matches</div><div><br>
</div></div><div><br></div><div style>I guessed Key was bound so I could use for pattern matching. It's very easy to fix it but I don't know why it doesn't work.</div><div><br></div><div><br></div><div style>Fixed version:</div>
<div style><br></div><div style><br></div><div>delete_key_from_list(Key, StatusList)-></div><div> lists:foldr(</div><div> fun(K, Acc) when K == Key -></div><div><span class="" style="white-space:pre"> </span> Acc;</div>
<div><span class="" style="white-space:pre"> </span> (Another, Acc) -></div><div><span class="" style="white-space:pre"> </span> [Another|Acc]</div><div> end,</div><div> [],</div><div> StatusList).</div>
</div>