-
Notifications
You must be signed in to change notification settings - Fork 0
/
chpt_8a.rb
executable file
·114 lines (62 loc) · 1.32 KB
/
chpt_8a.rb
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[]
[5]
['Hello', 'Goodbye']
flavor = 'vanilla' #not an array
[89.8,flavor, [true, false]] #an array
names = ['Ada', 'Belle', 'Chris']
puts names
puts''
puts names [0]
puts names [1]
puts names [2]
puts names [3]
puts''
other_peeps = []
other_peeps[3] = 'beebee Meaner'
other_peeps[0] = 'Ah-ha'
other_peeps[1] = 'Seedee'
other_peeps[0] = 'beebee Ah-ha'
puts other_peeps
language = ['English', 'Morwegain', 'ruby']
language.each do |lang|
puts'I love ' + lang + '!'
puts 'Don\'t you?'
end
puts''
puts 'And let\'s hear it for Java!'
puts '<crickets chirp in the distance>'
#Go-go-gadget-interger-method
3.times do
puts 'Hip-Hip-Hooray!'
end
2.times do
puts '...you can say that again...'
end
foods = ['artichoke', 'brioche', 'caramel']
puts foods
puts foods.to_s
puts foods.join(', ')
puts foods.join(' :) ') + ' 8)'
200.times do
puts []
end
puts''
favorites = []
favorites.push 'raindrops on roses'
favorites.push 'whisky on kittens'
puts favorites[0]
puts favorites.last
puts favorites.length
puts favorites.pop
puts favorites
puts favorites.length
puts 'please give me as many words as you would like, for me to sort.'
words = []
words = gets.chomp.push
while true
words = words.sort.push
end
puts''
puts chapter 1: 'Getting started'
puts chapter 2: 'Numbers'
puts chapter 3: 'letters'