<<>> 특수 형식으로 정의해요.
255보다 큰 정수를 사용하면, :: 연산자로 사용할 단위와 크기를 지정하지 않는 한 마지막 8비트만 사용해요.<>/2는 비트스트링, 바이너리, 문자열을 이어 붙일 때 쓸 수 있어요.<<255>> == <<0xFF>>
# Overflowing bits are truncated
<<256>> == <<0>>
<<256::size(16)>> == <<1, 0>>
<<"Hello">> == <<72, 101, 108, 108, 111>>
_널 바이트_는 <<0>>의 또 다른 이름이에요.
# This string has a string length of 5, but is made up of 7 bytes
string = "cześć"
String.length(string) != byte_size(string)
# Even emoji strings are encoded binaries
"👍" == <<240, 159, 145, 141>>
# Ignore the first 8 bytes, bind the remaining variable sized binary to `body`
<<_::binary-size(8), body::binary>>
문자열에도 똑같이 적용할 수 있어요:
# bind the first 5 bytes to `name`,
# match the string literal " the ",
# bind remaining bytes to `species`
<<name::binary-size(5), " the ", species::binary>> = <<"Frank the Walrus">>
{name, species}
# => {"Frank", "Walrus"}