Bird
0
0

Which of the following version constraints allows patch-level updates but prevents minor version changes?

easy📝 Conceptual Q2 of 15
Ruby - Gems and Bundler
Which of the following version constraints allows patch-level updates but prevents minor version changes?
A~> 2.3
B~> 2.3.0
C>= 2.3.0, < 3.0
D~> 2
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of the pessimistic operator ~>

    The operator ~> 2.3 means ">= 2.3 and < 3.0" allowing minor version updates. ~> 2.3.0 means ">= 2.3.0 and < 2.4.0" allowing patch updates only.
  2. Step 2: Identify which constraint restricts minor version changes

    ~> 2.3.0 restricts updates to patch versions within 2.3.x, preventing minor version 2.4 or higher.
  3. Final Answer:

    ~> 2.3.0 -> Option B
  4. Quick Check:

    Pessimistic operator with patch precision = ~> 2.3.0 [OK]
Quick Trick: Use ~> with three parts to lock minor version, allow patch updates [OK]
Common Mistakes:
  • Using ~> 2.3 allows minor updates, not just patch
  • Confusing >= with ~>
  • Assuming ~> 2 locks major version only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes