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:
Step 1: Review Ruby naming conventions
Local variables should start with a lowercase letter or underscore and use snake_case for readability.
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.
Final Answer:
user_email -> Option C
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
Master "Variables and Data Types" in Ruby
9 interactive learning modes - each teaches the same concept differently