Project

General

Profile

Bug #16947 ยป private_method.rb

example private method - kapitan_morgan (Yaromir Bartosh), 06/10/2020 12:17 PM

 
1
class Person
2
  def speak
3
    puts "Hey, Tj!"
4
  end
5

    
6
  def whisper_louder
7
    whisper
8
  end
9

    
10
  def whisper_self
11
    self.whisper
12
  end
13

    
14
  private 
15
  def whisper
16
    puts "His name's not really 'Tj'." 
17
  end 
18
end
19

    
20
p = Person.new
21

    
22
p.speak
23
p.whisper_louder
24

    
25
# should cause an error
26
# but in version 2.7.1 no error occurs
27
p.whisper_self