e6.5-3.rb

来自「ruby语言教程,Ruby是一种动态语言」· RB 代码 · 共 30 行

RB
30
字号
#E6.5-3.rb 

class Person    
  def speak
    "protected:speak  "
  end  
  
  def laugh
    "   private:laugh"   
  end 
  
  protected :speak
  private     :laugh
  
  def useLaugh(another)    
    puts another.laugh
  end  
  
  def useSpeak(another)   
    puts another.speak
  end  
  
end

p1=Person.new 
p2=Person.new

p2.useSpeak(p1)
#p2.useLaugh(p1) 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?