PostgreSQL

Enum types in Ruby

When I start a new project in Ruby, the first module I copy over is my custom little enum.rb.

Many popular programming languages have built-in support for enums. C, C++, C#, Go, Java, Rust, Swift, but also looser-typed languages like PHP and Python.

Ruby doesn’t have native support for enum types, but it’s not hard to add and add some clarity and cleanliness to your code.