Bird
0
0

Which of the following is the correct syntax to specify a gem version constraint for exactly version 1.5.2 in a Gemfile?

easy📝 Syntax Q3 of 15
Ruby - Gems and Bundler
Which of the following is the correct syntax to specify a gem version constraint for exactly version 1.5.2 in a Gemfile?
Agem 'rails', '1.5.2'
Bgem 'rails', '~> 1.5.2'
Cgem 'rails', '>= 1.5.2'
Dgem 'rails', '< 1.5.2'
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to specify exact version in Gemfile

    Specifying a version as a string without operators means exactly that version.
  2. Step 2: Check each option

    gem 'rails', '1.5.2' specifies exactly '1.5.2'. gem 'rails', '~> 1.5.2' allows patch updates. gem 'rails', '>= 1.5.2' allows any version >= 1.5.2. gem 'rails', '< 1.5.2' allows versions less than 1.5.2.
  3. Final Answer:

    gem 'rails', '1.5.2' -> Option A
  4. Quick Check:

    Exact version syntax = gem 'rails', '1.5.2' [OK]
Quick Trick: Use version string without operators for exact version [OK]
Common Mistakes:
  • Using ~> for exact version
  • Using >= which allows newer versions
  • Using < which excludes the version

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes