Bird
0
0

Given the Gemfile line gem 'rack', '~> 2.1.0', which of the following versions is allowed?

medium📝 Predict Output Q4 of 15
Ruby - Gems and Bundler
Given the Gemfile line gem 'rack', '~> 2.1.0', which of the following versions is allowed?
A2.0.9
B2.2.0
C2.1.5
D3.0.0
Step-by-Step Solution
Solution:
  1. Step 1: Interpret the pessimistic operator ~> 2.1.0

    This means versions >= 2.1.0 and < 2.2.0 are allowed.
  2. Step 2: Check each version against the range

    2.1.5 is between 2.1.0 and 2.2.0 (allowed). 2.2.0 is not less than 2.2.0 (excluded). 3.0.0 is greater than 2.2.0 (excluded). 2.0.9 is less than 2.1.0 (excluded).
  3. Final Answer:

    2.1.5 -> Option C
  4. Quick Check:

    ~> 2.1.0 allows patch updates only = 2.1.5 [OK]
Quick Trick: ~> x.y.z allows patch updates, excludes next minor version [OK]
Common Mistakes:
  • Including next minor version like 2.2.0
  • Allowing major version updates
  • Misunderstanding patch vs minor updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes