22,860 questions
1
vote
6
answers
223
views
Why do we need abstract methods in Enums
I've been studying Java for some time now to better understand what goes on inside some of the code parts.
While studying Enum, which I am used to using exclusively for listing various fixed values (...
1
vote
0
answers
45
views
EF Core + Npgsql: "column 'status' is of type application_status but expression is of type text"
I've been struggling for two days with a PostgreSQL enum type issue in Entity Framework Core. Despite all my configuration, EF Core keeps trying to send a string (`text`) to an enum column.
The ...
2
votes
3
answers
175
views
Can enum values be redeclared?
The C++ Coding guidelines, Enum.3: Prefer class enums over “plain” enums contains following example:
void Print_color(int color);
enum Web_color { red = 0xFF0000, green = 0x00FF00, blue = 0x0000FF };
...
0
votes
1
answer
130
views
Android: Filter CardViews in RecyclerView List with Room DAO
I have a RecylcerView List of CardViews. Each CardView holds user data that is saved in a Room database. Some of the CardViews have due dates that have been entered by the user with a TimePicker. I ...
0
votes
0
answers
36
views
Retrieve Oat++ ENUM documentation programmatically
I have an ENUM with some documentation about the values ("Description 1", "Description 2"):
ENUM(MyEnum, v_int32,
VALUE(VAL1, 3, "ME_VAL1", "Description 1"),...
3
votes
1
answer
70
views
Trying to reduce the verboseness of __post_init__ in a python dataclass
I am writing a Python config script that creates an array of input files in a domain-specific language (DSL), so my use case is a bit unusual. In this scenario, we want medium-level users to be able ...
2
votes
1
answer
192
views
Converting from 'int' to days of the week, Richard Reily book, C++
I'm working from the 2nd edition of "C++ (Teach Yourself Computing)" by Richard Reily, see here.
When he introduces enum, he gives the following code, which is supposed to output 'Today is 2'...
4
votes
3
answers
424
views
Backward and forward compatibility issues with protobufs in Google Pub/Sub
We use protocol buffers both for gRPC server-to-server communication and for publishing messages to Pub/Sub.
Pub/Sub is fairly sensitive to schema changes, not allowing any schema changes that would ...
1
vote
1
answer
89
views
Simplifying getting a specific type from an enum
I have a set of classes linked into an enum:
#[derive(Default)]
pub struct A {
}
#[derive(Default)]
pub struct B {
}
#[derive(Default)]
pub struct C {
}
enum Classes {
A(A),
B(B),
C(C),
...
1
vote
0
answers
91
views
How to check order of enum with fields?
Let's say there is an enum with fields with a specific order. e.g.,
pub enum MyValues {
U8(u8),
U64(u64),
U128(u128),
Str(Vec<U8>),
U16(u16),
}
How to add a test to make ...
1
vote
1
answer
80
views
Using strings as type-safe id keys
I am currently using an enum for the object ids in my array. This is type-safe and works well. However, it means I have to maintain two separate data structures: The enum and the array.
Instead, I ...
-3
votes
1
answer
69
views
How to declare a variant of a rust enum with a pre-existing variant outside of the enum?
I have code analogous to the following:
struct A(String);
impl A {
fn new(&str) -> Self
...
}
struct B(String);
impl B {
fn new(&str) -> Self
...
}
struct C(String);
...
4
votes
1
answer
72
views
Constrained type is unconstrained?
I've been writing Rust for a several months now, and I've come across this headscratcher:
I have the following code:
trait MyTrait {}
impl MyTrait for String {}
impl MyTrait for str {}
impl MyTrait ...
0
votes
0
answers
73
views
An enum with associated index and data for each variant
I am new to Rust, and I am trying to learn the language by solving puzzles on coding sites. For this reason, I can't use external crates, and I need a solution which relies only on the standard ...
1
vote
1
answer
36
views
need to combine an enum and a timesstamp in DRF
Django Admin: How to combine archived_at and archive_status into one archival source?
I’m building a feature to archive users via Django Admin. Currently, I’m using both a DateTimeField (archived_at) ...
-2
votes
2
answers
91
views
Enums in Java: empty line with semicolon? [duplicate]
Today I wanted to write a simple Java enum (using java 21) with a little help from my IntelliJ IDEA. Just a simple enum with one value.
This is what IntelliJ created for me:
public enum MySimpleEnum {
...
1
vote
1
answer
81
views
String as x-axis in Grafana xy plot
My goal is to plot a xy scatter plot in Grafana. X-axis is 'setting', and the potential values are 'off', 'idle', 'standby', and 'on'. On the y-axis I have 'performance' and the data type is real. My ...
0
votes
5
answers
3k
views
TypeScript Enum alternative following the use of --erasableSyntaxOnly flag
TypeScript has added the erasableSyntaxOnly flag, that doesn't let you use Enums.
Have looked for several alternative options. Like:
What's the best practice to implement an alternative to ...
1
vote
1
answer
170
views
Is there any way to obtain a listing of enum names and values in a typedef for QFlags? [duplicate]
As such I (questioner) am no longer looking for an answer but I am not sure on what grounds to recommend closing. It could possibly be helpful to someone.
Here's an example of what I mean (based on ...
0
votes
2
answers
73
views
How to update removed model choices in Django without breaking existing database values?
I'm working on a Django project where we use models.TextChoices for fields like current_status. Our client requested wording updates — for example, renaming "Contacted" to "Contacted ...
2
votes
0
answers
27
views
Angular Enum Type [duplicate]
I have urls defined like this:
E_one = '/url1/'
E_two = '/url2/'
E_three = '/url3/'
export LINKS = { E_one: E_one, E_two: E_two, E_three: E_three}
So I import 'LINKS', but then I want to dynamically ...
1
vote
1
answer
65
views
Methods for a TypeScript type alias
I have this Dir type alias that is a set of 8 cardinal directions, used as an enum:
type Dir = "N" | "NE" | "E" | "SE" | "S" | "SW" | "...
0
votes
2
answers
42
views
Python3 : circular reference in Enum instance(?)
For a Python3.13 project, I'm interested in objects created by Enum (e.g. MyEnum.VALUE); I need to serialize them ‘manually’ (=no marshal, no pickle). I think I've noticed several circular references ...
2
votes
3
answers
93
views
Use typescript enum values as class properties
I have a typescript enum MyEnum:
export enum MyEnum {
ALPHA = 'ALPHA',
BETA = 'BETA'
}
I want to use the enum values as properties of another class. I know can do stuff like that:
export class ...
2
votes
2
answers
70
views
Convert a union string to an enum
I have a situation where from upstream I get a union string, but downstream needs to use enums to express enumerated types.
The types happen to overlap perfectly, but I need a way to treat them as the ...