Ruby定义私有方法(private)的两种办法
Ruby定义私有方法(private)的两种办法
发布时间:2016-12-28 来源:查字典编辑
摘要:#定义私有方法途径1:classCdefpublic_methodprivate_methodenddefprivate_methodend...

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ruby专题学习
热门ruby专题学习
脚本专栏子分类