What would be the difference between matching like:
fun(Binary) ->
[Value, Rest] = binary:split(Binary, <<101>>)
end
and
fun(Binary) ->
[Value, <<Rest/binary>>] = binary:split(Binary, <<101>>)
end
I am thinking that one may simply increment a counter as it traverses the binary and keep the sub binary pointer and the other will copy a new binary. Any ideas?
I can think of pattern matching in two ways.
Method 1:
Method 2:
Unless you need to make it sure B is binary, Method 2 will take it longer, few micro seconds, because it’s not just assigning <<“fghi”>> to B, but also make it sure it is bianary.
However if you need more parsing than method 2, you can go further, which method 1 can’t do.