-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobj_01.rb
More file actions
executable file
·96 lines (75 loc) · 1.2 KB
/
robj_01.rb
File metadata and controls
executable file
·96 lines (75 loc) · 1.2 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
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env ruby
require "./ruler"
#-----------------------------------------------------------------------------
def ex_self
#Object#type is deprecated; use Object#class
#puts self.type
puts self.class
end
#-----------------------------------------------------------------------------
class Person
def sample
puts "Person_sample"
end
end
class Person
def sample2
puts "Sample2"
end
end
def ex_obj
other = Object.new
def other.pp
puts "ex_obj"
end
other.pp
p0 = Person.new
p0.sample
p0.sample2
p1 = Person.new
def p1.sample2
puts "P1 sample2"
end
p1.sample2
end
#-----------------------------------------------------------------------------
def ex_return
def sample_ret2(x)
return x, (x*2)
end
a, b = sample_ret2(10)
puts a
puts b
end
#-----------------------------------------------------------------------------
def ex_refer
a = "wojtek"
b = a
p a, b
b += "aaa";
p a, b;
def mo(x)
x[0] = x[0] + 1
end
x = [ 1 ]
p x
mo(x)
p x
undef mo
def mo(y)
y += 1
end
y = 1
p y
mo(y)
p y
end
#-----------------------------------------------------------------------------
R("self");
ex_self();
R("obj");
ex_obj();
R("ret");
ex_return();
R("reference");
ex_refer();