-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.rb
More file actions
67 lines (54 loc) · 915 Bytes
/
index.rb
File metadata and controls
67 lines (54 loc) · 915 Bytes
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
64
65
66
67
age = 10
discount = 10.5
gender = true
full = false
names = [1,2,3]
George = {
name: "George",
age: 60,
grandchildren: 10
}
puts George
# Hash
# cayoty = {
# name => "Cayoty",
# age => 20,
# grandparents => 4,
# career => "Software Engineer",
# workplace => "Moringa School"
# }
names = ["John", "James", "Ruby", "Natasha"]
pp names.inspect
# Conditionals, comparison operators
if names.length > 2 && names.length < 5
puts "Have a good day"
elsif (names.length == 2)
puts "Marvellous"
else
puts "Goodbye"
end
age = 18
if age == 18
puts "Adult"
elsif age < 18
puts "Child"
elsif age > 18
puts "Old enough"
end
unless names.length != 4
names.push("Simon")
else
puts "hello"
end
# Data Structures
def sum(num1, num2)
num1 - num2
end
sum(18, 30)
def looper(limit)
limit.times dp [i]
puts i
end
end
looper(3)
looper(5)