Ruby学习札记(五)访问作用域
public
private
protected,不赘述,你懂的
#无参的访问控制方法
class Bird
def fly #默认为public
end
private
def eat
end
protected
def run
end
public
def jump
end
end
#使用参数指定成员的访问级别
class Bird
def fly
end
def eat
end
def run
end
def jump
end
private(:eat)
protected(:run,:jump)
end
浙公网安备 33010602011771号