-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbad.erl
63 lines (52 loc) · 906 Bytes
/
bad.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
ex_case(Animal) ->
case Animal of
cat ->
evil;
dog ->
awesome
end.
ex_fun() ->
fun(Arg) when is_atom(Arg) ->
Arg;
(Arg) when is_list(Arg) ->
list_to_existing_atom(Arg)
end.
ex_if(Animal) ->
if
Animal == cat ->
boo;
Animal == bear ->
run_away;
true ->
pet_it
end.
ex_receive(Msg) ->
receive
Msg ->
received;
_Other ->
not_received
end.
ex_try(Car) ->
try
start_engine(Car)
catch
throw:missing_keys ->
missing_keys;
throw:no_gas ->
no_gas
end.
ex_try_of(Car) ->
try start_engine(Car) of
started ->
started;
{not_started, Reason} when Reason == ford ->
obviously;
Else ->
Else
catch
throw:missing_keys ->
missing_keys;
throw:no_gas ->
no_gas
end.