Bird
0
0

Find the style error in this Ruby code:

medium📝 Debug Q7 of 15
Ruby - Ecosystem and Best Practices
Find the style error in this Ruby code:
class Person
def initialize(name)
@name = name
end
end
AMissing indentation inside class and method
BIncorrect class keyword usage
CInstance variable should not start with @
DMethod name initialize is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Review indentation rules

    Ruby style guide requires 2 spaces indentation inside classes and methods.
  2. Step 2: Check code indentation

    Code lines inside class and method are not indented, violating style guide.
  3. Final Answer:

    Missing indentation inside class and method -> Option A
  4. Quick Check:

    Indent code 2 spaces inside class and method [OK]
Quick Trick: Indent 2 spaces inside classes and methods [OK]
Common Mistakes:
  • No indentation inside blocks
  • Wrong instance variable syntax
  • Misnaming initialize method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes