Bird
0
0

Why does Ruby require local variable names to start with a lowercase letter or underscore?

hard📝 Conceptual Q10 of 15
Ruby - Variables and Data Types
Why does Ruby require local variable names to start with a lowercase letter or underscore?
ATo allow spaces in variable names
BTo distinguish local variables from constants and global variables
CTo make variable names case-insensitive
DTo prevent variables from being reassigned
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby naming conventions purpose

    Ruby uses naming rules to differentiate variable types: local variables, constants, globals.
  2. Step 2: Explain why lowercase or underscore start is required

    Starting with lowercase or underscore marks local variables, uppercase marks constants, $ marks globals.
  3. Final Answer:

    To distinguish local variables from constants and global variables -> Option B
  4. Quick Check:

    Naming rules separate variable types = true [OK]
Quick Trick: Naming rules help Ruby know variable types [OK]
Common Mistakes:
  • Thinking naming affects case sensitivity
  • Believing naming prevents reassignment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes