Bird
0
0

How can you specify a gem version constraint that allows any version starting with 3.x but excludes all 3.5.x versions?

hard📝 Application Q9 of 15
Ruby - Gems and Bundler
How can you specify a gem version constraint that allows any version starting with 3.x but excludes all 3.5.x versions?
A>= 3.0, < 3.5, > 3.5.0, < 4.0
B>= 3.0, < 4.0, != 3.5.*
C~> 3.0, != 3.5.*
D>= 3.0, < 3.5, >= 3.6, < 4.0
Step-by-Step Solution
Solution:
  1. Step 1: Understand the requirement to allow 3.x but exclude 3.5.x

    We want versions from 3.0 up to 4.0 but exclude any 3.5.x versions.
  2. Step 2: Use version constraints with exclusion

    Using >= 3.0 and < 4.0 allows all 3.x versions. Adding != 3.5.* excludes all 3.5.x versions.
  3. Final Answer:

    >= 3.0, < 4.0, != 3.5.* -> Option B
  4. Quick Check:

    Use != to exclude specific versions in range = >= 3.0, < 4.0, != 3.5.* [OK]
Quick Trick: Use != with wildcard to exclude specific version series [OK]
Common Mistakes:
  • Trying to exclude versions with multiple ranges incorrectly
  • Using > 3.5.0 which excludes only patch versions
  • Assuming ~> can exclude specific minor versions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes