1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#定義私有方法途徑1: class C def public_method private_method end def private_method end private :private_method #定義方法為私有 end #定義私有方法途徑2: class C def public_method private_method end private def private_method #定義私有方法 end end C . new .public_method |