coding style - Correct way of writing parentheses in Ruby methods? -


What is the "acceptable" or "correct" way of writing brackets in Ruby mode?

Like:

  puts doc.instance_of? (Self.class.superclass.class)   

Or:

  puts the doctor. An example? (Self.class.superclass.class)   

Or:

  puts doc.instance_of? (Self.class.superclass.class)   

Or:

  puts doc.instance_of? (Self.class.superclass.class)    

2 and 3 are incorrect (@MyestoShort See the comment).

Between 1 and 4, just pick a style guide and stick with it. Compatibility The most important thing is that I am satisfied with the recommendation of 1 and it looks individually clear:

Here is an example of 2 breaking with a method Which takes an alternate second argument:

  def f (x, y = 1) x + y end f (1,2) # 3f (1) # 2f (1, 2 ) # Syntax error f (1), 2 # 3!    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -