Swift Enum Hub

Swift Enum Hub



Enum on Swift is a cool dude. In a single blog the coolness of Enum can not be expressed. As a result we have a total of four blog post including this one dedicated to enum on Swift. This blog post will act as a hub page for enum to ease the navigation in the realm on enum. We can consider this blog post as the index for Swift’s enum tutorial. Though the blog posts on this site are not written as typical tutorial containing the long setup and line by line of how to. This blog always consider you as a smart person who already knows the stuff. We are here to sharpen our crafts. Now let us shift our focus on enum again.

Background

At a glance

Below is the related post on enum on this blog.

Let us review all of them in short one by one.

Love for Enum

On our very first blog over enum, Love for Enum, we have the basic introduction with enum. So topic like rawValue, hashValue, associated value were discussed there. More importantly we discussed about the use case for each of those bases concepts of enum. And finally we answered one of the most commonly asked question: Why we can’t use associated value with hashValue together on enum. Even if you posses the basic knowledge about enum on Swift, though I will request you to visit that blog post at least once. Because those topic/concepts may seems very trivial on an overwatch position they are not. They are the building block of enum.

Love for Enum, continuing…

On our second blog post over enum, Love for Enum, continuing…, we moved on a bit more advanced topic. Such as generic usage on enum, Error definition through enum, why not to mutate enum, recursiveness of enum. Also the allCases and the frozenness of enum. This blog post moves us into a bit more advance level as we will start for a big jump on our next blog post on enum. A blog post about the case study on enum.

enum case study: Tic tac toe, through enum

Here comes the big part. Now we will implement the learned knowledge from the previous two blog post. We will build a case study which suits the enum nearly perfectly. On the building of Tic tac toe through enum we will get an insight of enum usage on real life. We briefly explain the cause of choosing different features of enum. Here we will get the fun of using Swift switch in action. Also the different version of Swift enum init. On the Tic tac toe, through enum blog post most of time we choose enum as our primary data container.

To develop this blog post we use the TDD approach. So when we have the source code, which is hosted publicly on GitHub, we will see a lot of test cases. On some future time we will cover the TDD.

mutating enum struct on Swift

This blog post is not directly connected to enum, rather it is more connect with the value type. Here on this blog post we will learn how we can mutate the value type. Even more is it ok do such mutation for value type. Whats the stand view of value type on this type of mutation.

End talk

There are some topics those are not discussed on the enum blog post series. Topic such as Swift enum codable and Swift struct & enum relation are not touched. May be on some future time we will.

The official Swift doc largely covers the topics of enum on Swift. But to cover some real life implementation of enum we talked a lot on this blog. Proper usage of enum can drastically change our capability on Swift. So keep digging for more enum treasure. Take care.

5 thoughts on “Swift Enum Hub

Leave a Reply

Notifications for mobidevtalk! Cool ;) :( not cool