Bird
0
0

Which of the following is the recommended way to name constants in Ruby according to the style guide?

easy📝 Conceptual Q2 of 15
Ruby - Ecosystem and Best Practices
Which of the following is the recommended way to name constants in Ruby according to the style guide?
AmyConstant
BMY_CONSTANT
Cmy_constant
DMyConstant
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby constant naming conventions

    Constants in Ruby should be all uppercase letters with underscores separating words.
  2. Step 2: Match options to this convention

    MY_CONSTANT uses uppercase letters with underscores, which is correct.
  3. Final Answer:

    MY_CONSTANT -> Option B
  4. Quick Check:

    Ruby constants = ALL_CAPS_WITH_UNDERSCORES [OK]
Quick Trick: Constants are ALL_CAPS with underscores in Ruby [OK]
Common Mistakes:
  • Using camelCase for constants
  • Using lowercase letters
  • Using PascalCase for constants

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes