Guest User

Untitled

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. class Parent
  2. def hello
  3. 'hello'
  4. end
  5. protected :hello
  6. end
  7. class Child < Parent
  8. def say_hello(name)
  9. puts Child.new.hello + ', ' + name
  10. end
  11. end
  12. Child.new.say_hello('hoge') # => 'hello, hoge' is printed
  13. puts Parent.new.hello # => NoMethodError is thrown
Add Comment
Please, Sign In to add comment