---
title: Ruby's Pessimistic Operator
teaser:
tags: web,ruby,open source
author: Dan Croak
published_on: 2010-12-29
---

Do you know Ruby's pessimistic operator? It looks like this:

    ~>

You've seen it in some `Gemfile`s. Here's an example

    gem 'rails', '~> 3.0.3'
    gem 'thin',  '~> 1.1'

`~> 3.0.3` means that when you `bundle install`, you'll get the highest-released
gem version of `rails` between the range `>= 3.0.3` and `< 3.1`.

`~> 1.1` means that when you `bundle install`, you'll get the highest-released
gem version of `thin` between the range `>= 1.1` and `< 2.0`.

Using the pessimistic operator in combination with consistent [Semantic
versioning](http://semver.org/) by gem authors, we can theoretically achieve
better stability in our dependencies.

[Read more on the tradeoffs](https://thoughtbot.com/blog/post/35717411108/a-healthy-bundle)
or [read our current guidelines on Bundler](https://github.com/thoughtbot/guides/tree/master/best-practices#bundler).
