Project

General

Profile

Bug #16947 ยป private_method.rb

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

 
class Person
def speak
puts "Hey, Tj!"
end

def whisper_louder
whisper
end

def whisper_self
self.whisper
end

private
def whisper
puts "His name's not really 'Tj'."
end
end

p = Person.new

p.speak
p.whisper_louder

# should cause an error
# but in version 2.7.1 no error occurs
p.whisper_self
    (1-1/1)