erlang中的替代字符_

erlang中_才是万能替代字符, _后面接任意字符就变成了变量名称了

Eshell V5.7.4  (abort with ^G)
1> f().
ok
2> A = <<16:32>>.
<<0,0,0,16>>
3> <<A1:16, _A:16>> =A.
<<0,0,0,16>>
4> _A.
16
5> <<A1:16, _:16>> =A.
<<0,0,0,16>>
6> _.                
* 1: variable '_' is unbound
7> <<A1:16, _:8, _:8>> =A.
<<0,0,0,16>>
8> <<A1:16, _A2:8, _A2:8>> =A.
** exception error: no match of right hand side value <<0,0,0,16>>
但是_*的写法能避免编译时报unuse

你可能感兴趣的:(erlang,_,替代)