Bird
0
0

Which of the following is the correct syntax to define a let variable named user with value "Alice"?

easy📝 Syntax Q12 of 15
Ruby - Testing with RSpec and Minitest
Which of the following is the correct syntax to define a let variable named user with value "Alice"?
Abefore { user = "Alice" }
Blet user = "Alice"
Clet(:user) { "Alice" }
Dlet user { "Alice" }
Step-by-Step Solution
Solution:
  1. Step 1: Recall let syntax

    let takes a symbol argument and a block returning the value: let(:name) { value }.
  2. Step 2: Check each option

    let(:user) { "Alice" } matches correct syntax. Options B and D miss parentheses or block syntax. before { user = "Alice" } uses before, not let.
  3. Final Answer:

    let(:user) { "Alice" } -> Option C
  4. Quick Check:

    Correct let syntax uses symbol and block [OK]
Quick Trick: Use parentheses and block for let: let(:name) { value } [OK]
Common Mistakes:
  • Omitting parentheses around symbol
  • Using assignment instead of block
  • Confusing let with before syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes