Ruby defines two ways of private methods

Time:2019-8-19
# Define Private Approach 1:
class C
  def public_method
    private_method
  end
 
  def private_method 
  end
 
  Private: private_method Defines the method as private
end
 
# Define Private Approach 2:
class C
  def public_method
    private_method
  end
 
  private
  Def private_method Defines private methods
  end
end
 
C.new.public_method

Recommended Today

[NOIP2001 Popularization Group] Seek Ranking

Question analysis: The question mentions the pre-order, in-order, and post-order arrangement of trees, so we need to know what these three arrangements mean first. 3 (depth-first) permutations of binary trees: Pre-order, "root left and right". That is, for each subtree of the binary tree, first visit its root, and then traverse its left and right […]