虚位以待(AD)
虚位以待(AD)
首页 > 脚本专栏 > ruby > Ruby定义私有方法(private)的两种办法

Ruby定义私有方法(private)的两种办法
类别:ruby   作者:码皇   来源:互联网   点击:

这篇文章主要介绍了Ruby定义私有方法(private)的两种办法,本文直接给出代码实例,需要的朋友可以参考下
    #定义私有方法途径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 #定义私有方法 endend C.new.public_method

相关热词搜索: Ruby 定义 私有方法 private 办法