Bird
0
0

Which of the following is the correct way to indent Ruby code according to the style guide?

easy📝 Syntax Q12 of 15
Ruby - Ecosystem and Best Practices
Which of the following is the correct way to indent Ruby code according to the style guide?
A2 spaces
B4 spaces
C1 tab
DNo indentation
Step-by-Step Solution
Solution:
  1. Step 1: Recall indentation rules

    The Ruby style guide specifies using 2 spaces for indentation to keep code clean and consistent.
  2. Step 2: Evaluate options

    4 spaces and tabs are common in other languages but not recommended in Ruby style guide.
  3. Final Answer:

    2 spaces -> Option A
  4. Quick Check:

    Indent with 2 spaces [OK]
Quick Trick: Always indent Ruby code with 2 spaces, never tabs [OK]
Common Mistakes:
  • Using tabs instead of spaces
  • Using 4 spaces like in Python or JavaScript
  • No indentation causing unreadable code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes