• A summary of the differences among public, private and protected in Ruby


    Focus on private and protected public The default is public, which can be accessed globally. This does not explain private C + +, “private” means “private to this class”, but Ruby means “private to this instance”In C + +, for class A, as long as you can access class A, you can access the private […]

  • Talk about Ruby’s Private and Protected


    I’ve been wrestling with this program for a long time. The concept of private in Ruby is really weird… class Test private def test_print puts ‘test’ end end class Test2 < Test def test_print2 # Self. test_print#=> cannot be invoked by adding self here. Private method `test_print’called for # (NoMethodError) Test_print#=> Called without self end […]