I have started learning Erlang recently and came across the following error while trying to pattren match
The following expression is working fine:
{A,_,[B|_],{B}}={abc,23,[22,x],{22}}.
Resulting in
A = abc
B = 22
The following expression is not working:
{A,_,[_|B],{B}}={abc,23,[22,x],{x}}.
Is resulting in
** exception error: no match of right hand side value {abc,23,[22,x],{x}}
However if I replace the ',' in [22 , x with a | like the following its working find and bounding x to B
{A,_,[_|B],{B}}={abc,23,[22|x],{x}}.
{abc,23,[22|x],{x}}
B.
x
Any explanation about this would highly appreciated.
Many thanks in advance