Bird
0
0

Which of the following correctly composes two Procs proc_a and proc_b so that proc_a runs first and its result is passed to proc_b?

easy📝 Syntax Q3 of 15
Ruby - Functional Patterns in Ruby
Which of the following correctly composes two Procs proc_a and proc_b so that proc_a runs first and its result is passed to proc_b?
Acombined = proc_b >> proc_a
Bcombined = proc_a + proc_b
Ccombined = proc_a >> proc_b
Dcombined = proc_a * proc_b
Step-by-Step Solution
Solution:
  1. Step 1: Understand Proc composition

    The operator >> composes two Procs so that the output of the first is input to the second.
  2. Step 2: Apply correct operator

    Using proc_a >> proc_b means proc_a runs first, then proc_b receives its output.
  3. Final Answer:

    combined = proc_a >> proc_b -> Option C
  4. Quick Check:

    Check operator semantics [OK]
Quick Trick: Use >> to chain Procs in order [OK]
Common Mistakes:
  • Using + operator which is invalid for Procs
  • Reversing order with proc_b >> proc_a
  • Using * operator which is undefined for Procs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes