Bird
0
0

You need to store a user's email address in a local variable following Ruby naming conventions. Which variable name is best?

hard📝 Application Q8 of 15
Ruby - Variables and Data Types
You need to store a user's email address in a local variable following Ruby naming conventions. Which variable name is best?
AuserEmail
BUser_email
Cuser_email
Duser-email
Step-by-Step Solution
Solution:
  1. Step 1: Review Ruby naming conventions

    Local variables should start with a lowercase letter or underscore and use snake_case for readability.
  2. Step 2: Evaluate options

    userEmail uses camelCase, which is not idiomatic Ruby.
    User_email starts with uppercase letter, treated as constant.
    user_email uses snake_case, recommended style.
    user-email contains a hyphen, invalid character.
  3. Final Answer:

    user_email -> Option C
  4. Quick Check:

    Snake_case with lowercase start [OK]
Quick Trick: Use snake_case for local variables [OK]
Common Mistakes:
  • Using camelCase instead of snake_case
  • Starting variable names with uppercase letters
  • Including invalid characters like hyphens

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes