jsh*_*jlo 2 binary erlang pattern-matching binaries
为什么会出现badmatch错误?我无法弄清楚为什么会失败:
<<IpAddr, ":*:*">> = <<"2a01:e34:ee8b:c080:a542:ffaf:*:*">>.
Run Code Online (Sandbox Code Playgroud)
您需要指定大小,IpAddr以便它可以进行模式匹配:
1> <<IpAddr:28/binary, ":*:*">> = <<"2a01:e34:ee8b:c080:a542:ffaf:*:*">>.
<<"2a01:e34:ee8b:c080:a542:ffaf:*:*">>
2> IpAddr.
<<"2a01:e34:ee8b:c080:a542:ffaf">>
Run Code Online (Sandbox Code Playgroud)