Category "enums"

How to confirm an enumeration to Identifiable protocol in Swift?

I'm trying to make a list with the raw values of the cases from an enumeration with the new SwiftUI framework. However, I'm having a trouble with conforming the

Python Enum and Pydantic : accept enum member's composition

I have an enum : from enum import Enum class MyEnum(Enum): val1 = "val1" val2 = "val2" val3 = "val3" I would like to validate a pydantic field bas

Mongoose - array of enum strings

I have a Schema that has a property with the type of array of strings that are predefined. This is what I've tried to do: interests: { type: [String], e

how to override the toString method of an enum in dart

I'm just wondering if it's possible to override the toString method in dart this is what I have: enum Style{italic, bold, underline} Style.italic.toString() //

Perform checks on a nested enum

I have an enum which is defined as follows: enum MyEnum { X(u32), Y(Vec<MyEnum>), Z(Vec<MyEnum>), } As you can see, the enum is nested

How to make a Swift enum with associated values equatable

I have an enum of associated values which I would like to make equatable for testing purposes, but do not know how this pattern would work with an enum case wit

Flutter / Dart Convert Int to Enum

Is there a simple way to convert an integer value to enum? I want to retrieve an integer value from shared preference and convert it to an enum type. My enum i

Python Enum: How to get enum values with multiple attributes

I have defined two enums with attributes. When I want to access an enum element by specifying its attribute it works for enum A (one attribute) but not for enum

Why is Swift compiler complaining about circular reference when I comment out seemingly unrelated code?

Creating a brand new macOS Command Line Tool project in Xcode Version 13.3 (13E113), and replacing the contents of main.swift with the following code: import Fo

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?