defmodule BinaryGarden do
def handshake(<< a :: size(16), "00", c :: binary-size(2) >>) when c == "AB" do
"You testing me?"
end
def handshake(<< a :: size(16), b :: size(16), c :: size(16) >>), do: "Hello there!"
def handshake(_), do: "Don't talk to strangers"
end
iex(1)> BinaryGarden.handshake("1200AB")
"You testing me?"
iex(1)> BinaryGarden.handshake("120034")
"Hello there!"
iex(2)> BinaryGarden.handshake("20034")
"Don't talk to strangers"