Bird
0
0

You want to specify a gem version constraint that allows any patch update for version 3.2 but prevents minor version updates to 3.3 or higher. Which constraint should you use?

hard📝 Application Q15 of 15
Ruby - Gems and Bundler
You want to specify a gem version constraint that allows any patch update for version 3.2 but prevents minor version updates to 3.3 or higher. Which constraint should you use?
Agem 'mygem', '>= 3.2.0', '< 3.3.0'
Bgem 'mygem', '>= 3.2.0'
Cgem 'mygem', '~> 3.2'
Dgem 'mygem', '== 3.2.*'
Step-by-Step Solution
Solution:
  1. Step 1: Understand patch vs minor version updates

    Patch updates change the last digit (e.g., 3.2.1), minor updates change the middle digit (e.g., 3.3.0).
  2. Step 2: Analyze each constraint

    gem 'mygem', '>= 3.2.0', '< 3.3.0' explicitly allows >= 3.2.0 and < 3.3.0 (3.2.x only). gem 'mygem', '>= 3.2.0' sets only lower bound, allows 3.3+. gem 'mygem', '~> 3.2' allows >= 3.2.0 < 4.0 (allows 3.3). gem 'mygem', '== 3.2.*' uses invalid syntax.
  3. Step 3: Select the correct constraint

    The explicit range gem 'mygem', '>= 3.2.0', '< 3.3.0' precisely prevents minor updates beyond 3.2.x.
  4. Final Answer:

    gem 'mygem', '>= 3.2.0', '< 3.3.0' -> Option A
  5. Quick Check:

    Explicit range prevents minor version updates [OK]
Quick Trick: Use explicit >= and < to lock minor version [OK]
Common Mistakes:
  • Using ~> 3.2 which allows minor updates
  • Trying invalid wildcard syntax
  • Not specifying upper bound to prevent minor updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes