Guest User

Untitled

a guest
Feb 18th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. defmodule Math do
  2. def add(a \ 2, b) do
  3. a + b
  4. end
  5. end
  6.  
  7. defmodule Math do
  8. def add(a \ 2, b) do
  9. a + b
  10. end
  11. end
  12.  
  13. iex (1)> c("math.ex")
  14.  
  15. iex (2)> Math.add(1, 8) # add/2, pois estamos fazendo o match de 1 com `a`
  16. 9
  17.  
  18. iex (3)> Math.add(8) # add/1, pois `a` está com match padrão a 2.
  19. 10
Add Comment
Please, Sign In to add comment