设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
123
返回列表 发新帖
楼主: zh99998
打印 上一主题 下一主题

脚本求解释

 关闭 [复制链接]

Lv2.观梦者

天仙

梦石
0
星屑
620
在线时间
184 小时
注册时间
2008-4-15
帖子
5023

贵宾

21
发表于 2009-2-15 03:26:15 | 只看该作者
private 就是隐藏用的
例如某些只需要在本类內調用的公用方法(utility method),而不想被外人拿来调用,就可以用private
这些公用方法大概就是一些进行私底下计算用的


Public, Protected, Private Methods:

Instance methods may be public, private, or protected.

    *

      Public Methods: Methods are normally public unless they are explicitly declared to be private or protected. A public method can be invoked from anywhere, there are no restrictions on its use.
    *

      Private Methods: A private method is internal to the implementation of a class, and it can only be called by other instance methods of the same class.
    *

      Protected Methods: A protected method is like a private method in that it can only be invoked from within the implementation of a class or its subclasses. It differs from a private method in that it may be explicitly invoked on any instance of the class, and it is not restricted to implicit invocation on self.

These methods can be declared with three methods named public, private, and protected.. Here is the syntax
class Point
  # public methods go here

  # The following methods are protected
  protected

  # protected methods go here

  # The following methods are private
  private

  # private methods go here
end
[quote]
Here is a class with a private utility method and a protected accessor method:
[quote]
class Widget
  def x                       # Accessor method for @x
    @x
  end
  protected :x                # Make it protected

  def utility_method          # Define a method
    nil
  end
  private :utility_method     # And make it private
end
VA脚本开工中...
偷窃脚本1.0 - 已完成
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
46
在线时间
10 小时
注册时间
2007-5-27
帖子
2558

第1届Title华丽大赛新人奖

22
发表于 2009-2-15 06:16:28 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-1-10 21:23

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表