1>B1= <<1,2,3,4,5,6,7,8>>.   %%对B1赋值 
<<1,2,3,4,5,6,7,8>> 

2> <<_Other1:24,D1:3/binary,_other2/binary>> =B1. 
<<1,2,3,4,5,6,7,8>> 

其中"_Other1:24" 表示读取24位数据,而"D1:3/binary"表示在之后读取3字节数据以binary方式存在D1,"_other2"则表示其余的binary统统放入_other2. 

再看看结果: 

3> _Other1. 
66051 
4> D1. 
<<4,5,6>> 
5> _other2. 
<<7,8>> 

(_Other1取24bit,相当于2#000000010000001000000011.) 
Erlang的拆包/匹配过程就是这么简单. 

相关文章:

  • 2022-01-22
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2021-07-04
  • 2021-07-07
猜你喜欢
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
相关资源
相似解决方案