Search code examples
erlangguard

Guard not catching the correct data


Code and Debug Info

So here's my code, I don't understand why my second guard isn't catching the data. As you can see on the debugger the data is the same. Unless I'm blind I cannot see the problem


Solution

  • Data is bound to the value "hey\n", but the {tcp,S,_} tuple you're receiving has a 3rd element of "HEY\n", which does not equal the value of Data. Change that receive clause to:

    {tcp,S,Data2} ->
    

    or some other unbound variable name — anything other than Data — and all will be well.