Ruby定义私有方法(private)的两种办法
摘要:#定义私有方法途径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定义私有方法(private)的两种办法】相关文章:
★ Ruby单元测试框架TestUnit的替代者MiniTest介绍
★ Ruby元编程之梦中情人method_missing方法详解
上一篇:
Ruby中类变量和实例变量的比较
下一篇:
ruby基本数据类型简明介绍