Skip to main content

Questions tagged [enum]

A data type consisting of a set of named values called elements, members or enumerators of the type.

Filter by
Sorted by
Tagged with
5 votes
1 answer
315 views

I am wiriting am application which needs to store information about an industrial process where products go through the following, strictly sequential phases: ...
Afelium's user avatar
  • 133
5 votes
3 answers
435 views

I'm developing an ASP.NET Core application using .NET 8, following the Onion Architecture. In our domain model, we use Enumeration classes instead of traditional ...
James Black's user avatar
2 votes
1 answer
119 views

I am building an application with a lot of integer values which need to be mapped to strings for user CLI and logging. Using array LUT does not provide boundary checks so I want to generate conversion ...
jackhab's user avatar
  • 185
4 votes
1 answer
197 views

Because I think maintainability can be done better with strings instead of plain enumerator-values when doing fstream IO, I wanted a replacement struct in my project that behaves like an ...
ScratchingTheSurface's user avatar
8 votes
3 answers
198 views

Thanks to G. Sliepen, who gave me a lot very meaningful & useful advice on my implementation about overloading bit operators for a special scoped enum. Now I have modified the code snippet to ...
John's user avatar
  • 469
4 votes
1 answer
414 views

I watched a YouTube video (https://www.youtube.com/watch?v=z-0-bbc80JM) talking about the power of enums in rust for data modelling. In the video, there's an example of a state machine of a simple ...
rafaelgdgs's user avatar
2 votes
0 answers
179 views

I've been looking to have "smarter" or "better" enum functionality in C#. There are a few GitHub/NuGet projects out there, but they seem to target newer versions of .NET and I ...
Jesse C. Slicer's user avatar
2 votes
3 answers
292 views

I have defined a data structure in Java that allows to manage certain type of elements like a Queue, with the special feature of using 2 inner rows (windows) to attend elements: ...
Cardstdani's user avatar
2 votes
1 answer
102 views

So I've decided to flex showcase my "enum that accepts strings etc..." here. I don't know if it's great but I'm pretty sure it's decent. It is implemented in less than 200 lines of code (not ...
PinkTurtle's user avatar
0 votes
3 answers
262 views

To avoid the use of magic numbers, I created a static class to store some integer values that are represented inside a database. I avoided using enums because I need to cast them every time I use them....
Abcd's user avatar
  • 103
4 votes
1 answer
1k views

I needed to find a way to convert a bunch of enums to string for displaying in C++. The two main ways I found when searching was using dark magic macros or voodoo magic template metaprogramming. As I ...
adepierre's user avatar
  • 135
2 votes
4 answers
236 views

See code from this question about the advantages of Enums. ...
Jagerber48's user avatar
1 vote
3 answers
136 views

I was answering a question, Java Exception Error Enumerations Anti-pattern, on Software Engineering Stack Exchange and found myself writing up a fair bit of code. It could use a code review so I'm ...
candied_orange's user avatar
4 votes
3 answers
2k views

I have an ever growing switch case statement I plan on adding 3 more case statements to. Given an int, compare it to an enum, and call ...
Luminous's user avatar
  • 143
5 votes
3 answers
8k views

I need to convert the ENUM to a respective string value for which I came up with two approaches and I'm trying to see why would a second approach be better than the first one if even in terms of ...
xyf's user avatar
  • 508
2 votes
2 answers
454 views

Application: replacing enum type / description tags in modular software, allowing adding new enum values without updating one definition. Say we have a video processing pipeline not unlike gstreamer. ...
Stefan's user avatar
  • 813
6 votes
4 answers
1k views

I'm struggling to find a proper name for a specific method (in code named NameOfExtension), and would also like some feedback about its implementation. I am ...
c-chavez's user avatar
  • 163
-1 votes
2 answers
159 views

I would like to share this post with the community since at first glance it is very promising. Storing flags in the database is something that I have been interested in doing for a while since it ...
jwize's user avatar
  • 199
0 votes
1 answer
56 views

I am looking to write a JavaScript class BasicType with five fixed instances INT, FLOAT, <...
Ray Toal's user avatar
  • 765
3 votes
2 answers
261 views

For a project, I'm using 3 columns to define teeth positions in a database. For these positions, I want to generate numbers according to this link. Currently, I'm using a ...
Bas's user avatar
  • 699
1 vote
1 answer
138 views

I have an Enum the encapsulates numeric primitives (u8, i8, u16, i16, u32, i32, u64, i64, f32, f64) into a common type called "Number". I want to implement a PartialOrd train for the enum ...
Darko's user avatar
  • 111
15 votes
4 answers
3k views

I'm using Python's Enum to define the physical units in which a value is expressed. Eventually, I want to add them as an attribute to my ...
ElRudi's user avatar
  • 271
8 votes
1 answer
2k views

I want to enable bitmask-like behavior (ie. overloaded operator|, operator& and operator^...
Frederic Schönberger's user avatar
5 votes
3 answers
2k views

I have for some time been frustrated by the limitations around enumerations in VBA. Googling didn't find anything really simple and comprehensive. So after a bit of head scratching I came up with the ...
Freeflow's user avatar
  • 655
1 vote
1 answer
339 views

Put together a RadioMenu class that can use a Enum to generate a Single-Selection Radio Button Menu. My main question is about whether there's a way to remove the ...
Tim Hunter's user avatar
4 votes
0 answers
332 views

I tried to implement something like a C++ enum class in Fortran. That means it should be typesafe and scope bound. (No comparison between integers and enum values ...
mcocdawc's user avatar
  • 974
9 votes
2 answers
5k views

This is a snippet of code written in Python 3.9 to implement the concept of "enum unions": an enum made up of several sub-enums whose set of members is the union of the sub-enums' members. ...
Anakhand's user avatar
  • 645
6 votes
3 answers
285 views

Just as a learning exercise, I am implementing a poker game simulator. I am purposefully not searching for ready made tutorials showing how to do this, relying mostly on the python docs - that way I ...
msm1089's user avatar
  • 197
2 votes
1 answer
105 views

I have a Type class that will have many instances. I get the instances from a web service. The Type class has a ...
user8297969's user avatar
3 votes
0 answers
98 views

Getting started in VB.net I've written this console calculator based heavily off Nicholas Dingle youtube channel (in case it looks familiar). What I want to do is have a separate sub called ...
wesley delk's user avatar
2 votes
1 answer
3k views

from enum import Enum from fastapi import FastAPI app = FastAPI() Hi Defined a route and a Enum Class for the same but the Enum Class looks ugly. ...
pyd's user avatar
  • 239
5 votes
1 answer
8k views

I have a List that I want to compare to an Enum. If a.Value is found in the Enum we return <...
indofraiser's user avatar
2 votes
2 answers
274 views

At our office there is this piece of code (the original author isn't employed anymore, so I can't ask him). Does anybody have an idea, what he did there? Is there any advantage of using this struct <...
Matthias Burger's user avatar
5 votes
1 answer
372 views

I'm have recyclerView which is needed for displayed for show list of my audio records. I added the ability to sort my audio records. Please take a look at the code that I use for sorting and tell me ...
Destroyer's user avatar
  • 459
3 votes
1 answer
2k views

I created a simple enum macro that creates a to_string method for the enum. This has been done before, but my version is designed to compile quickly. From what I ...
sudo rm -rf slash's user avatar
1 vote
1 answer
59 views

I have a feature with feature flagging enabled, basis the condition I want to load different pages in my screen, to achieve this I have the following enum: ...
User3's user avatar
  • 241
3 votes
2 answers
177 views

I am developing applications for android. In my application, the user can add information about his weight and watch the progress of weight change. I decided to add filtering of the elements according ...
Destroyer's user avatar
  • 459
6 votes
2 answers
527 views

Motivation In the standard Python library enum, a subclass of Enum would create all its members upon class creation. This can ...
user141240's user avatar
3 votes
1 answer
140 views

I have implemented the integer residue ring \$ \mathbb{Z}/m\mathbb{Z} \$ and the integer multiplicative residue group \$ (\mathbb{Z}/m\mathbb{Z})^* \$. Functionalities include: In \$ \mathbb{Z}/m\...
user141240's user avatar
2 votes
1 answer
115 views

I had old enum, I converted it to Enumeration class and added one method inside (isValid). I am not sure if it is good approach ...
renathy's user avatar
  • 121
4 votes
1 answer
364 views

I am playing with learning PowerShell classes, and I have a validation situation that kind of lends itself to Enums, as shown in the first example. With Enum ...
Gordon in Ukraine's user avatar
7 votes
3 answers
8k views

Often when I find myself working with magic number enum values and I want to know what they represent, so I create an array of strings in order to print out their label. This macro automates that ...
Alex Angel's user avatar
6 votes
2 answers
507 views

My aim is to assign a color to each workday in a week. So if a user enters a day as a str, then I can know which color it should have. Because colors and workdays ...
aura's user avatar
  • 251
4 votes
2 answers
910 views

I have Grade enum and there is a static method to convert a string value to the particular enum value. ...
Rafael's user avatar
  • 143
6 votes
2 answers
367 views

I've created a class that creates key->value pairs but also value->key pairs - i.e. a reversible hash-map. This is because I want to be able to switch between corresponding members of 2 enums ...
Greedo's user avatar
  • 2,635
3 votes
1 answer
664 views

AFAIK Octave still does not support enumerations, so I've done my best to write a workaround. The question is if there is something missing in code below, or maybe something can be improved? The ...
littleBOT's user avatar
6 votes
2 answers
287 views

Consider I have many enums (Java) that looks somewhat like this: ...
Hallel's user avatar
  • 163
2 votes
1 answer
172 views

Users can have a Cookie called lang that contains either the value "default=1" (English) or "default=2" (French). This cookie is used to determine their preferred ...
Word Rearranger's user avatar
4 votes
1 answer
435 views

I want to create a factory to return all Source instances that match given entry parameters- that is, I want to iterate through some Collection of objects and for each entry check boolean method. I ...
Khayn's user avatar
  • 43
2 votes
1 answer
63 views

Inspired by this blogpost I decided to try and make it possible to have ranges of enum members that dwim, aka. that contain the actual members and not a stringified ...
Holli's user avatar
  • 221

1
2 3 4 5 6