您现在的位置是:网站首页> 编程资料编程资料

Ruby定义私有方法(private)的两种办法_ruby专题_

2023-05-26 482人已围观

简介 Ruby定义私有方法(private)的两种办法_ruby专题_

 #定义私有方法途径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 

-六神源码网