Based on a question on StackOverflow: Homebrew install specific version of formula

The distilled steps:

Create the git repository containing homebrew formulas:

$ brew update

Choose the specific version:

$ brew versions scala
2.9.1    git checkout 53a1f0b /usr/local/Library/Formula/scala.rb
2.9.0.1  git checkout cb1ab23 /usr/local/Library/Formula/scala.rb
2.9.0    git checkout 4002978 /usr/local/Library/Formula/scala.rb
2.8.1    git checkout 0e16b9d /usr/local/Library/Formula/scala.rb
2.8.0    git checkout fdb41a3 /usr/local/Library/Formula/scala.rb
2.7.7    git checkout 6a18e38 /usr/local/Library/Formula/scala.rb
2.7.6    git checkout a82e823 /usr/local/Library/Formula/scala.rb
2.7.5    git checkout e9dd256 /usr/local/Library/Formula/scala.rb

For these to work you have to be in the working-directory:

$ cd /usr/local/Library/Formula

Execute the git code for your version:

$ git checkout 4002978 /usr/local/Library/Formula/scala.rb

And install:

$ brew install scala

(if you’ve already install an older version, you may have to brew remove scala)

Voilà.