iex(149)> %Riak.Object{} = r
%Riak.Object{bucket: "user", content_type: 'application/json',
data: "han solo the second", key: "hero",
metadata: {:dict, 3, 16, 16, 8, 80, 48,
{[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []},
{{[], [], [], [], [], [], [], [], [], [],
[["content-type", 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47,
106, 115, 111, 110],
["X-Riak-VTag", 52, 107, 107, 70, 111, 69, 106, 68, 118, 108, 52, 107, 68,
50, 97, 121, 86, 55, 104, 121, 56, 68]], [], [],
[["X-Riak-Last-Modified" | {1461, 97432, 474244}]], [], []}}},
type: :undefined,
vclock: <<107, 206, 97, 96, 96, 96, 204, 96, 202, 5, 82, 60, 202, 156, 255, 126, 126, 232, 153, 215, 192, 192, 224, 167, 152, 193, 148, 40, 152, 199, 202, 112, 131, 191, 251, 2, 95, 22, 0>>}
iex(150)> match?(%Riak.Object{}, r)
true
iex(151)> match?(%Riak.Object{}, r)
true
iex(152)> case r do
...(152)> %Riak.Object{} = r -> true
...(152)> _ -> false
...(152)> end
true
iex(153)> is_map(r) && Map.has_key?(r,:__struct__) && r.__struct__ == Riak.Object
true
Created
April 19, 2016 20:56
-
-
Save binarytemple/17d3060da0233ce632fc192734b6d637 to your computer and use it in GitHub Desktop.
match on elixir structs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment