Bird
0
0

Identify the style error in the following Ruby code snippet:

medium📝 Debug Q14 of 15
Ruby - Ecosystem and Best Practices
Identify the style error in the following Ruby code snippet:
class my_class
  def say_hello
    puts 'Hello world'
  end
end
AClass name should be snake_case
BMethod name should be CamelCase
CClass name should be CamelCase
DString should use double quotes
Step-by-Step Solution
Solution:
  1. Step 1: Check class naming conventions

    Ruby style guide requires class names to use CamelCase, not snake_case.
  2. Step 2: Verify method and string style

    Method name is correctly snake_case; single quotes are allowed if no interpolation needed.
  3. Final Answer:

    Class name should be CamelCase -> Option C
  4. Quick Check:

    Classes use CamelCase [OK]
Quick Trick: Classes and modules use CamelCase, not snake_case [OK]
Common Mistakes:
  • Using snake_case for class names
  • Changing method names to CamelCase incorrectly
  • Forcing double quotes when not needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes