[erlang-questions] confused by the grammar of split_binary/2 in the example of mp3_sync

lang qiu <>
Sun Oct 12 18:20:05 CEST 2008


Hi,

I am confused by the grammar of split_binary/2 in the example of mp3_sync in
the book "Programming Erlang",

get_word(N, Bin) ->
   * {_,<<C:4/binary,_/binary>>} = split_binary(Bin, N), C.*

I understand that *@spec split_binary(Bin, Pos)* -> {Bin1, Bin2} but how
does the above clause work ? How does it make C get the first 4 bytes of Bin
starting from N ?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081013/65c2b8ad/attachment.html>


More information about the erlang-questions mailing list