When reviewing the turbo-rails source code, I noticed something that I had never seen before:

# test/dummy/config/application.rb
case (rails_version = ENV["RAILS_VERSION"])
when "main", nil then 7.1
else rails_version.to_f
end

Question: But what is: "main", nil then 7.1?

You could write as the following:

when rails_version === "main" || rails_version === nil

or

when rails_version === "main" , rails_version === nil

then is somewhat superfluous IMO. You can use it if you want everything on the same line.

Adopt it in an example

If you’re reading this, and you’ve learned something, I would encourage you to adopt the above into a trivial sample of your own. The process of doing so is what enables you to ‘learn’:

def golf_score(score)
      case score
      when 1 
            "ace or condor"
      when 2 
            "albatross or double_eage"
      when 3 then "eagle"
      when 4 then "birdie"
      when 5 then "par"
      when 6 then "bogie"
      when 7 then "double bogie"
      when 8 then "snowman"
      when 9, 10, 11, 12 then "bruh, my condoelences"
      else
            "pick up and move onto the next hole"
      end
end

golf_score(3) # => eagle
golf_score(9) # => "bruh, my condoelences"
golf_score(10) # => "bruh, my condoelences"

Written on August 7, 2025