The double colon (::) has two uses. Both could be subscribed as “being of type”:
- In binaries, it is used to explain what size(bit/byte/multiple bytes) an element in the binary is. An example, taken from the Parsing UDP with Binary Pattern Matching blog post:
<<
_header :: size(240), # 30 bytes * 8 = 240 bits
priority_code :: bitstring-size(8),
agent_number :: little-unsigned-integer-size(32),
message :: bitstring-size(320)
>> = data
When pattern matching with binaries, a size has to be specified for all but the last element to-be-matched element.
2.In specifying what return type a function has, when writing @spec, @type or @callback attributes:
@spec fibonacci(int) :: int
@type num_or_str :: number | string
@callback read_description(Entity.t) :: iodata






















