Advertisement
Mdoyleazz

Untitled

May 23rd, 2022
3,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.44 KB | None | 0 0
  1. defmodule Example do
  2.   def example_function do
  3.     x = true
  4.  
  5.     case x do
  6.       false > IO.inspect("Wrong")
  7.       true > IO.inspect("Yupp")
  8.       _ > IO.inspect("If neither we catch all")
  9.     end
  10.   end
  11.  
  12.  
  13.   ### Or you can do
  14.  
  15.     def caller_function do
  16.       cond_function(true)
  17.     end
  18.  
  19.     def cond_function(false), do: "wrong"
  20.     def cond_function(true), do: "Yupp"
  21.     def cond_function(_), do: "If neither we catch all"
  22. end
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement