public
Created

  • Download Gist
test.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/usr/bin/env ruby
 
class Name
def hello
puts "Hello!"
end
 
def say_bye
bye()
end
 
private
def bye
puts "Good bye"
end
end
 
# x = Name.new
# x.hello # works fine
# x.say_bye # works fine
# x.bye # can't call this one, only a non-private method within the same class can call it, better say 'use it'.
 
class Surname < Name
def test
bye()
end
end
 
y = Surname.new
y.test # works
y.hello # works
y.bye # doesn't work.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.