-
Notifications
You must be signed in to change notification settings - Fork 1
/
good.erl
62 lines (49 loc) · 921 Bytes
/
good.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
ex_case(Animal) ->
case Animal of
chicken ->
eggs;
cat ->
icky_kittens;
dog ->
puppies
end.
ex_fun() ->
fun(Arg) ->
ok
end.
ex_function() ->
ok.
ex_if(Arg) ->
if
Arg == cat ->
do_not_adopt;
Arg == dog ->
your_new_best_friend
end.
ex_receive() ->
receive
Msg ->
received;
_Other ->
not_received
end.
ex_try(Car) ->
try
start_engine(Car)
catch throw:missing_keys ->
missing_keys
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.