Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. defmodule Foo do
  2.  
  3. @code1 0xA7
  4. @code2 0x1F
  5. @codes [@code1, @code2]
  6.  
  7.  
  8. def bar(<<type::signed-8, tail::binary>>), when type in @codes do: IO.inspect "Signed: #{type}"
  9.  
  10. end
  11.  
  12.  
  13. # Both of these equal the same result
  14. <<type::signed-8, tail::binary>> = <<0xA7, 0x00>>;
  15. <<type::unsigned-8, tail::binary>> = <<0xA7, 0x00>>;
  16.  
  17. # The whey won't this get into the def for bar?
  18. Foo.bar <<0xA7, 0x00>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement