-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobj_04.rb
More file actions
executable file
·74 lines (59 loc) · 992 Bytes
/
robj_04.rb
File metadata and controls
executable file
·74 lines (59 loc) · 992 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
68
69
70
71
72
73
74
#!/usr/bin/env ruby
def ex_each()
puts "-----------#{__method__.to_s}--------------"
a = [1, 2, 3, 10, -20, -17]
a.each { puts "aa" }
end
def ex_each_iter()
puts "-----------#{__method__.to_s}--------------"
a = [1, 2, 3, 10, -20, -17]
a.each { |a|
puts "aa #{a}"
}
puts "-----------"
for n in (1..3)
puts n
end
end
def ex_range()
puts "-----------#{__method__.to_s}--------------"
a = [1, 2, 3, 10, -20, -17]
a.each do
| ai |
puts ai
end
end
def ex_times()
puts "-----------#{__method__.to_s}--------------"
n = 3
n.times do
puts "@ "
end
n.times do |ni|
puts "> #{ni}"
end
10.downto(1) do |x|
print "#{x} ";
if (x == 1) then
puts ""
end
end
1.step(19, 2) do |oddnum|
print "#{oddnum} "
if (oddnum == 19) then
puts ""
end
end
end
def ex_eachline()
puts "-----------#{__method__.to_s}--------------"
s = "woj\nasd"
s.split("\n").each do |l|
puts l
end
end
ex_each()
ex_each_iter()
ex_range()
ex_times()
ex_eachline()