ruby系列教材(18):Specifying Access Control
来源:百度文库 编辑:神马文学网 时间:2024/07/08 10:53:26
本篇的内容主要描述Access Control的实现:
1)方式一
class MyClass
def method1 # default is ‘public‘
#...
end
protected # subsequent methods will be ‘protected‘
def method2 # will be ‘protected‘
#...
end
private # subsequent methods will be ‘private‘
def method3 # will be ‘private‘
#...
end
public # subsequent methods will be ‘public‘
def method4 # and this will be ‘public‘
#...
end
end
2)方式二
class MyClass
def method1
end
# ... and so on
public :method1, :method4
protected :method2
private :method3
end
*在public 等后面加上Symbol literals
1)方式一
class MyClass
def method1 # default is ‘public‘
#...
end
protected # subsequent methods will be ‘protected‘
def method2 # will be ‘protected‘
#...
end
private # subsequent methods will be ‘private‘
def method3 # will be ‘private‘
#...
end
public # subsequent methods will be ‘public‘
def method4 # and this will be ‘public‘
#...
end
end
2)方式二
class MyClass
def method1
end
# ... and so on
public :method1, :method4
protected :method2
private :method3
end
*在public 等后面加上Symbol literals
ruby系列教材(18):Specifying Access Control
ruby系列教材(12):Virtual Attributes
ruby系列教材(14):Class Variables
ruby系列教材(15):Class Methods
ruby系列教材(13):Attributes, Instance Variables, and Methods
802.11 MAC (Media Access Control)
现代秘书系列教材
ACCESS
工作管理 (job control),Linux技术文章,Linux系列教程,Linux
ThinkPad - Access IBM系列预装软件及其功能一览表
数字动画基础(数字媒体系列教材新世纪高等学校教材)
In Control
关于 Ruby - Ruby 官方网站
国际经济学(对外经济贸易大学远程教育系列教材)章昌裕
手写速记与电子速记(现代秘书系列教材)
刑法(高职高专法律系列教材)目录
Ruby QuickRef
Ruby简介
ruby网址
ruby笔记
Access表达式
Access表达式
ACCESS数据库
process control and management