Bird
0
0

Which symbol is used to start an instance variable name in Ruby?

easy📝 Conceptual Q2 of 15
Ruby - Classes and Objects
Which symbol is used to start an instance variable name in Ruby?
A#
B@
C$
D%
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby variable prefixes

    Instance variables always start with the '@' symbol in Ruby.
  2. Step 2: Identify correct symbol

    @ is '@', which matches the instance variable prefix.
  3. Final Answer:

    @ -> Option B
  4. Quick Check:

    Instance variable prefix = @ [OK]
Quick Trick: Instance variables always start with @ in Ruby [OK]
Common Mistakes:
  • Confusing @ with $ (global variables)
  • Using # which is for comments
  • Using % which is for hashes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes