Search code examples
erlang

Compare bytestrings in Erlang


Why in Erlang is <<14>> not the same as <<"\r">> if the character \r has the value 14?

If I do:

<<14>> = <<"\r">>.

I get

** exception error: no match of right hand side value <<"\r">>


Solution

  • You're using the wrong integer value; carriage return is decimal 13, not 14:

    1>  <<13>> = <<"\r">>.
    <<13>>