-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecision.ex
More file actions
49 lines (40 loc) · 1.08 KB
/
Decision.ex
File metadata and controls
49 lines (40 loc) · 1.08 KB
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
defmodule Decision do
def main do
do_stuff()
end
def do_stuff do
age = 16
if age >= 18 do
IO.puts("Can Vote")
else
IO.puts("Can't Vote")
end
unless age === 18 do
IO.puts("You are not 18")
else
IO.puts("You are 18")
end
cond do
age >= 18 -> IO.puts("You can vote")
age >= 16 -> IO.puts("You can drive")
age >= 14 -> IO.puts("You can wait")
true -> IO.puts("Default")
end
case 2 do
1 -> IO.puts("Entered 1")
2 -> IO.puts("Entered 2")
_ -> IO.puts("Default")
end
IO.puts("Ternary: #{if age > 18, do: "Can Vote", else: "Can't Vote"}")
my_stats = {175, 6.25, :Derek}
IO.puts("Tuple #{is_tuple(my_stats)}")
my_stats2 = Tuple.append(my_stats, 42)
IO.puts("Age #{elem(my_stats2, 3)}")
IO.puts("Size : #{tuple_size(my_stats2)}")
my_stats3 = Tuple.delete_at(my_stats2, 0)
my_stats4 = Tuple.insert_at(my_stats3, 0, 1974)
many_zeroes = Tuple.duplicate(0, 5)
{weight, height, name} = {175, 6.25, "Derek"}
IO.puts("Weight : #{weight}")
end
end