Skip to content
loading...

re: I've never become overly convinced that switch statements are that much cleaner than `if else if else if else if else` VIEW POST

TOP OF THREAD FULL DISCUSSION
re: That's why we never have switch in Python 😁 And, the dictionary is always a better and cleaner alternative for the ugly switch. def my_switcher...
 

Elixir :)

def my_switcher("a"), do: 1
def my_switcher("b"), do: 2
def my_switcher(), do: 3

iex(1)> Example.my_switcher("a")
1
iex(2)> Example.my_switcher("b")
2
iex(3)> Example.my_switcher()
3
 
 

I quite like cond as well for certain situations as well.

code of conduct - report abuse