Better Programming

Advice for programmers.

Follow publication

Member-only story

Comparable Enums in Swift 5.3

Eric Yang
Better Programming
Published in
3 min readJul 23, 2020
Photo by Greg Rakozy on Unsplash

1. Group Related Values at Enumeration

Photo by Johannes Plenio on Unsplash

Enumeration, or Enum for short, is a popular data type in many languages. It groups related values in a type-safe way within the code.

In Swift, Enumeration adopts many features supported by the first-class type, like struct, and class. It has initializers to provide an initial case value. It can be extended to expand functionality. Enum can have computed properties and instance methods to provide additional information. It also can implement protocol to align the behavior.

Enumeration is introduced with a pair of braces with the enum keyword.

2. Boilerplate to Compare Enum Cases

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Eric Yang
Eric Yang

Written by Eric Yang

Senior iOS engineer🚀, double degrees with Computer Science⚡Content writer? Why not!🚀

Write a response