I. Spaces and tabs
Use space indentation (95.364%)
Use Tab indent (4.636%)
Based on 1,001,987 submissions
Ii. widest line
80 characters (92.618% characters)
120 characters (5.893% characters)
150 characters (1.489% characters)
Based on 1,057,374 submissions
3. Whether to use spaces around operators, colons, and curly brackets after commas and semicolons
Do not use spaces (73.366%)
Copy codeThe Code is 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 codeThe Code is 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
Iv. Default Parameters
Front and back spaces (59.151%)
Copy codeThe Code is as follows:
Def some_method (arg1 =: default, arg2 = nil, arg3 = [])
# Do something...
End
There is no space before and after or only one space (40.849%)
Copy codeThe Code is as follows:
Def some_method (arg1 =: default, arg2 = nil, arg3 = [])
# Do something...
End
Based on 19,213 submissions
5. Long numbers
Do not use underline (97.984%)
Copy codeThe Code is as follows: num = 1000000
Underline (2.016%)
Copy codeCode: num = 0000000_000
Based on 133,530 submissions
6. Whether parentheses are omitted when no parameter is set
Omit brackets (98.556%)
Copy codeThe Code is as follows:
Def some_method
# Do something...
End
Parentheses (1.444%) are not omitted)
Copy codeThe Code is as follows:
Def some_method ()
# Do something...
End
Based on 267,404 submissions
7. Use parentheses around parameters when defining functions
Omitted (62.867%)
Copy codeThe Code is as follows:
Def some_method arg1, arg2
# Do something...
End
Not omitted (37.133%)
Copy codeThe Code is as follows:
Def some_method (arg1, arg2)
# Do something...
End
Based on 365,121 submissions