diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index b7db7df6279793c582a299ebcf2e194eb6d48a69..2c0ebbbf8a2841fb9976d57f12da5f3b55640e74 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -92,7 +92,9 @@ module SharedEnvExtension
   def compiler
     @compiler ||= if (cc = ARGV.cc)
       COMPILER_SYMBOL_MAP.fetch(cc) do |other|
-        if other =~ GNU_GCC_REGEXP then other
+        case other
+        when GNU_GCC_REGEXP
+          other
         else
           raise "Invalid value for --cc: #{other}"
         end