-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobj_03.rb
More file actions
executable file
·73 lines (61 loc) · 899 Bytes
/
robj_03.rb
File metadata and controls
executable file
·73 lines (61 loc) · 899 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
#!/usr/bin/env ruby
require "./ruler"
def ex_arr()
a = [ 1, 3, -1, 10, -19, 20 ]
b = [ 1, 3]
puts "Min\t#{a.min}"
puts "Max\t#{a.max}"
puts "Sort\t#{a.sort}"
end
def ex_arr2()
a = [ 1, 3, -1, 10, -19, 20 ]
b = [ 1, 3]
c = [ 100, 200 ]
p "a:", a
p "b:", b
p "a-b:"
p (a - b)
p "a & b:"
p (a & b)
p "c:"
p c
p "a | c:"
p (a | c)
end
def ex_grep()
ws = %w(wojtek adam koszek jola koszek)
puts ws.grep(/^[wa]/)
end
def ex_hash()
h = Hash.new
h["a"] = "aaaa"
h["b"] = "bbbb"
h["c"] = "cccc"
p h
p h["qwe"]
end
# Oh... This is so weird.
def ex_hash2()
ha = {
'name' => "wojciech",
'name2' => "adam",
'surname' => "koszek"
}
p ha
p "---------------------"
p ha.keys
p ha.values
p "---------------------"
p ha.key?("name")
p ha.key?("name3")
end
R("array0")
ex_arr()
R("array1")
ex_arr2()
R("grep")
ex_grep()
R("hash")
ex_hash()
R("hash2");
ex_hash2()