One, Space and tab
Indent with spaces (95.364%)
Use tab indent (4.636%)
Based on 1,001,987 submissions
Second, maximum line width
80 characters (92.618%)
120 characters (5.893%)
150 characters (1.489%)
Based on 1,057,374 submissions
Three, operator, colon, curly braces around, comma, semicolon after the use of space
Do not use spaces (73.366%)
Copy Code code as follows:
sum = 1 +2
A,b = 1, 2
1>2? True:false;puts ' Hi '
[1, 2, 3].each {|e| puts E}
Use spaces (26.634%)
Copy Code code as follows:
sum = 1 + 2
A, B = 1, 2
1 > 2? True:false; Puts ' Hi '
[1, 2, 3].each {|e| puts E}
Based on 911,301 submissions
Four, default parameters
Front and back spaces (59.151%)
Copy Code code as follows:
def some_method (arg1 =:d efault, arg2 = nil, arg3 = [])
# do something ...
End
No spaces or only one space (40.849%)
Copy Code code as follows:
def some_method (arg1=:d efault, Arg2=nil, arg3=[])
# do something ...
End
Based on 19,213 submissions
Five, long numbers
Do not use underline (97.984%)
Copy Code code as follows:
Use underline (2.016%)
Copy Code code as follows:
Based on 133,530 submissions
whether to omit parentheses when there is no argument
Ellipsis brackets (98.556%)
Copy Code code as follows:
def Some_method
# do something ...
End
Do not omit parentheses (1.444%)
Copy Code code as follows:
def Some_method ()
# do something ...
End
Based on 267,404 submissions
Whether to use parentheses around parameters when defining functions
Omitted (62.867%)
Copy Code code as follows:
def Some_method Arg1, arg2
# do something ...
End
Not omitted (37.133%)
Copy Code code as follows:
def some_method (Arg1, arg2)
# do something ...
End
Based on 365,121 submissions