Category "enums"

Python derived enum missing required positional argument

I'm trying to define an object-valued enum, and I'm running in an error of "missing 1 required positional argument" in enum_member.__init__(*args) A basic examp

Getting values for an enum?

I have an enum: enum Type: int { case OFFENSIVE = 1; case SPAM = 2; case IRRELEVANT = 3; } I understand I can get all types and their values with T

Using objects as the values of an Enum?

I'm currently trying to create an enum/constant-based system for defining colours in Python. I want to avoid having to use strings when attempting to use/access

Python: overloading the `__call__` dunder method of a class that inherits Enum

Consider the following: from enum import Enum class A(int, Enum): def __new__(cls, value): def call(cls, value): print("HELLO 1" +

Serialize Enum as DisplayName or EnumMember Value

I have an enum declared in c#. I have a Display Name/ EnumMember value annotation and Student Class. I'm using asp.net core 2.2+ version with Odata. [DataContra

Enum of structs in Swift 3.0

I am trying to create an enum of a struct that I would like to initialize: struct CustomStruct { var variable1: String var variable2: AnyClass var

How to get the number of elements (variants) in an enum as a constant value?

Is there a way to extract the number of elements in an enum? Simple example (with imaginary number_of_elements method): enum FooBar { A = 0, B, C, }; println

How to read and write Enum into parcel on Android?

Here is my model class: public enum Action { RETRY, SETTINGS } private int imageId; private String description; private String actionName; private Action

UML modelling enumeration with attributes

I would like to create an UML diagram with Java enumerations (enum), that have one or more attributes, but I am confused about how to do it. For example an enum

How to access a Swift enum associated value outside of a switch statement

Consider: enum Line { case Horizontal(CGFloat) case Vertical(CGFloat) } let leftEdge = Line.Horizontal(0.0) let leftMaskRightEdge

How to get all possible values for an existing ENUM or SET - field

I'm using Doctrine in Symfony4. How do I retrieve all possible values for an ENUM or SET column on this base?

TypeScript enum to object array

I have an enum defined this way: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milest

How to make toMap and fromMap method for Enums class dart flutter?

I used an enum variable in a class. Now I want to implement the toMap and fromMap methods for the class. enter code here enum ColorNumber { inc, dec, none }

error: ALTER TYPE ... ADD cannot run inside a transaction block

I am trying to add new type value to my existing types in PostgreSQL. But I get the following error error: ALTER TYPE ... ADD cannot run inside a transactio

How to define enum mapping in OpenAPI?

I am designing an API and I want to define an enum Severity which can have values LOW, MEDIUM or HIGH. Internally Severity gets stored as an integer so I want t

Python enum iteration over subset

I would like to iterate over a subset of the following enum class Items(enum.Enum): item1 = 0 item2 = 1 item3 = 2 item4 = 3 item5 = 4 i

The type or namespace name 'Parse' does not exist in the namespace 'Enum'

I have System in my namespace, what am I missing? I am brand new to C# and am following a course on Udemy and following a book titled C#8.0 and .NET Core 3.0 -

How to get enum value by string or int

How can I get the enum value if I have the enum string or enum int value. eg: If i have an enum as follows: public enum TestEnum { Value1 = 1, Value2

In Rust, is there a way to iterate through the values of an enum?

I come from a Java background and I might have something like enum Direction { NORTH, SOUTH, EAST, WEST} and I could do something with each of the values in tur

Converting Protobuf3 with enum to JSON in Go

How can I convert grpc/protobuf3 message to JSON where the enum is represented as string? For example, the protobuf message: enum Level { WARNING = 0;