-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhelloworld.rb
More file actions
83 lines (66 loc) · 1.22 KB
/
helloworld.rb
File metadata and controls
83 lines (66 loc) · 1.22 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
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
def showsomething
puts("hello, world, in function")
end
def practicefor
for ss in 1...10
puts('hello')
end
end
def testarray
games = ["StarCraft", "Portal", "Uncharted"]
for index in 0...games.length
puts(games[index])
end
end
def testiter
games = ["God of War II", "Burnout", "Battlefield"]
games.each {|each_game| puts each_game}
games.each do
|each_game|
puts each_game, "- Item"
end
end
def testiterspecial
games = ['a','b','c']
puts games.collect {
|each_game|
each_game.capitalize
}
caped = games.collect do
|each|
each.capitalize
end
puts caped
end
def testwhile
ss = 5
while ss > 0
puts ss
ss -= 1
end
end
def testif
condition = 'cc'
if condition == 'cc'
puts 'condition is right.'
end
puts 'condition is right' if condition == 'cc'
end
def testarrayoperation
array = ['a', 'b', 'c', 'd']
puts array.push("e")
puts array.pop
puts array
puts array.unshift("1")
end
begin
showsomething
puts("hello, world.")
practicefor
testarray
testiter
testiterspecial
testwhile
testif
testarrayoperation
end