|
|
|
|
|
by ragnese
1614 days ago
|
|
So... You have two declarations, one of which is a real array that's allocated at runtime. Is that really better than an enum? Not to mention, there's a slight mental overhead to parsing this. When I see this code, I might wonder if there's a reason for this to be an array. I might wonder if the order is intentional. An enum has a more clear intent. My only complaint is that enums are not string-by-default, so we end up writing our variants twice: enum MyType {
A = 'a',
B = 'b',
}
|
|
To be clear, the enum is also defined at runtime. So this specifically isn't a difference.