Bird
0
0

Which of these is the correct way to name a Ruby variable following conventions?

easy📝 Syntax Q3 of 15
Ruby - Ecosystem and Best Practices
Which of these is the correct way to name a Ruby variable following conventions?
Amy_variable
BmyVariable
CMy_variable
Dmy-variable
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby variable naming rules

    Ruby variables use snake_case, all lowercase with underscores.
  2. Step 2: Check each option

    my_variable matches my_variable which is correct; others break conventions or syntax.
  3. Final Answer:

    my_variable -> Option A
  4. Quick Check:

    Variables use snake_case = B [OK]
Quick Trick: Use lowercase with underscores for variables [OK]
Common Mistakes:
  • Using camelCase for variables
  • Starting variable names with uppercase
  • Using hyphens in names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes