Creating enum from dynamic array

I have a scenario where I need to create an enum array from a dynamic array.
But I am not able to quite get it correctly.
Any other data type which is preferable in this case?

Can you show us what you mean?

For example, I have an Array defined at runtime.
Lets say it will contain values like following. Length is not fixed.

var arr : String = ["Monday", "January", "2025", "Username"]

Now I want to create enum out of it after it gets filled with values like:

enum userData {
case data1: "Monday"
case data2: "january"
case data3: "2025"
case data4: "username"

How can I achieve it?

Why do you think you need an enum?

You cannot dynamically add cases to an enum. All of an enum's cases will be known at compile-time.

What sort of behavior are you looking for? Be specific.

Terms of Service

Privacy Policy

Cookie Policy