Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Parent
- def hello
- 'hello'
- end
- protected :hello
- end
- class Child < Parent
- def say_hello(name)
- puts Child.new.hello + ', ' + name
- end
- end
- Child.new.say_hello('hoge') # => 'hello, hoge' is printed
- puts Parent.new.hello # => NoMethodError is thrown
Add Comment
Please, Sign In to add comment