Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10
Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 22.214.171.124 release ready!
Owner and Founder. Opencart
Before knowing the indirect enum, I will give an overview of the enum. An enum defines the same or common type for a group of related values and provides features to work with those related values in a type-safe manner in developing the module.
We can also add the associated values with the enum cases as:
But in this blog, I will demonstrate to you what will happen if we try to pass the associated value as enum itself.
And we get the compiler error: Recursive enum ‘Webkul’ is not marked ‘indirect’ and look as:
Enums are value types, due to this Apple memory management works on compile-time. And we have an idea that how many memory counts we need to allocate for each instance.
When we add the one value type object inside the same value type object then we create a recursion. In case of this recursion, it is not possible that how much memory can be required for that object. So we need to know how can we deal with this situation.
Apple in swift introduces the indirect enumerations which tell the compiler to insert the necessary layer of indirection.
You can also write indirect before the beginning of the enumeration to enable indirection for all of the enumeration’s cases that have an associated value:
Indirect compiles the data and store the enum’s data behind a pointer. Add another layer of static memory size is allocated for storing the data. Thus after these optimizations, no need to make the instance of Enum big enough to hold the whole data.
I hope this blog will help you in the understanding of recursive enumerations if still you have any comments, questions, or recommendations, feel free to post them in the comment section below!
For other blogs, please click here.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.