forked from FrankRycak/Wyncode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeek_1_sample_code
94 lines (82 loc) · 1.7 KB
/
Week_1_sample_code
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# title of section
# code paragraph
# whitespace
# tip calculator
# bill = 40
# num_people = 3
# tip_percent = 0.20
#
# tip = bill * tip_percent
# total = bill + tip
# my_share = total / num_people
# puts my_share
# string interpolation
# age = 17
# puts "I'm " + age.to_s + " years old."
# puts "I'm #{age} years old."
# single-quotes doesn't interpolate
# puts 'I\'m #{age * 20} years old.'
# mutators
# arr = [1,2,3,3]
# arr.delete(3)
# p arr
# str = "abc"
# str.upcase
# p str
# str.upcase!
# p str
# if/then
# dead_people = ["Ethel", "Mortimer", "Buford"]
# alive_people = ["Kelly", "Joe", "Megan"]
# sick_people = alive_people.slice(0, 2)
# p sick_people
# p dead_people.include? 'Mortimer'
# p dead_people.include? 'Kelly'
# name = "Kelly"
#
# if dead_people.include?(name)
# puts "Don't send questionnaire to #{name}"
# elsif sick_people.include?(name)
# puts "Don't send a questionnaire to #{name} yet."
# else
# puts "Send questionnaire to #{name}"
# end
# name = "Kelly"
#
# if alive_people.include?(name)
# puts "Send questionnaire to #{name}"
# end
# name = "Kelly"
#
# unless dead_people.include?(name)
# puts "Send questionnaire to #{name}"
# else true
# puts "hi"
# end
# if false
# i can put whatever I want here and Ruby doesnt care
# else
# # blocks can be multiple lines
# puts "Hi"
# puts "Hello"
# end
# embedded ifs
# if alive_people.include?(name)
# if sick_people.include?(name)
# puts "Send questionnaire to #{name} later"
# else
# puts "Send questionnaire to #{name} now"
# end
# end
# for name in alive_people
# puts "Send questionnaire to #{name}"
# end
# i = 0
# while (i < 10) do
# puts i
# i -= 1
#
# if ((i > 100) or (i < -100))
# break
# end
# end