enums's questions - English 1answer

15.402 enums questions.

I have an enum type defined within a module. How do I export it to be accessible from outside once the module has been loaded? enum fruits { apple pie } function new-fruit { Param( [...

I'm using one enum in MVC application, which looks like the following enum, public enum School { DVB=1, AVD=2, ASB=3 } And I'm getting the only single character from database for each ...

I want to create a UITableViewController that accepts an enum as it's data source. The thing is, I have quite a few enums that I want it to be able to handle. I created a protocol called ...

A.swift: struct ApiRequest { static func getUrl() { // MyEnum.oneDay ---> Use of undeclared type 'MyEnum' } } B.swift: public enum MyEnum: String { case oneDay = "1d" ...

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 variable3: Int init (variable1: ...

Edit: This post is not a duplicate, those other solutions do not work in allowing me to use the bitwise operators. I want to do something like this: public static class EnumExt { public static ...

I have the following enum: public enum EventType : int { [Display(Description = "Downtime")] Downtime = 0, [Display(Description = "Speed")] Speed = 1, [Display(Description = "...

I have an enum: public enum AppEnums { SERVICE_ERROR, CONNECTION_ERROR; } and I want to use it in an intDef of Android Annotation: @IntDef({AppEnums.CONNECTION_ERROR, AppEnums.SERVICE_ERROR}...

Iterate over values in Flags Enum?

13 answers, 45.527 views c# enums
If I have a variable holding a flags enum, can I somehow iterate over the bit values in that specific variable? Or do I have to use Enum.GetValues to iterate over the entire enum and check which ones ...

I'd like to give documentation for each member of a python enum in a way that IPython can find it. What I have right now is something like: class Color(Enum): """ RED: The color red GREEN:...

I am trying to make a program to represent a deck of cards. I am using two enumerations to define a class Card. Then in main I am trying to assign suit and rank to a card. public final class Card { ...

I have an enum, which looks like public enum Animal { ELEPHANT, GIRAFFE, TURTLE, SNAKE, FROG } and I want to do something like Animal frog = Animal.FROG; Animal snake = Animal.SNAKE; ...

I need a Generic function to retrieve the name or value of an enum based on the XmlEnumAttribute "Name" property of the enum. For example I have the following enum defined: Public Enum Currency &...

I need some help with an ENUM dropdown using Tag Helper. I found lots exemples binding a model to Selectlist and some using ENUM but all of them, about CREATE action, and Im facing problems with ...

Is there a way to do something like this? enum MyType { Left, Right, #[cfg(universe = "normal")] Port = Left, #[cfg(universe = "normal")] Starboard = Right, #[cfg(...

I'm trying to use protobuf2 enums in golang but I cannot figure it out. I created a simple protobuf file: syntax = "proto2" ; package enum ; message Foo{ ...

It seems that from TypeScript 2.4 onwards String Enums are a feature. However the following does not work: enum Foo { A = "A", B = "B" } var foo : Foo = "A"; Initializer type string not ...

I am trying to make a Battleship game for a uni project. The project description mentions that in one of the classes(abstract class Ship) I should create a method called placeShip that places a ship ...

I have few enums like the following: public enum Season { SPRING, SUMMER, AUTUM, WINTER } public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } I am ...

I have the following enum that describes error codes: typedef enum { et_general = 0, et_INVALID_CLI_FLAG = 1, ... et_undef = 500 } EErrorType; The main reason why I ...

I am relatively new to java and I have been assigned a project. I need to make a rather complicated(for a newbie) battleship game. Here, I try to call switch cases in class Player from class Tile. ...

I am currently using Enumeratum 1.5.13 in Scala 2.12.6. I have the following defined: sealed abstract class PartOfSpeech(val value: Int) extends IntEnumEntry case object PartOfSpeech extends IntEnum[...

I have restful services that accept enum values as either the number OR the string, but always return just the number. Is there a way to type them? Here's what I kinda want, but it is not ...

Here is my enum: public enum StaffRanks { HELPER("helpers"), MODERATOR("moderators"), ADMINISTRATOR("administrators"), DEVELOPER("developers"), OWNER("owners"); private ...

I have following enum in our code: public Class Test { Status status; } public enum Status : short { NotStarted = 0, Inprogress, Completed, } What will be the value of status in ...

Enumeration Scope

5 answers, 4.199 views c enums
Quick question: If I have enums like: enum EnumA { stuffA = 0 }; enum enumAA { stuffA = 1 }; What happens here when you refer to stuffA? I thought you would refer to them like EnumA.stuffA and ...

I was thinking of implementing an enum that defines the state of a game object, and I wanted to know if I could directly use flags within the enum's definition, instead of defining the object's state ...

I know that there is issue with creating string enums using Typescript, even in v2.4+ I'm using typescript 2.8 and Angular 6. I would like to have an enum and to freely get string value from enum, ...

I'm trying to achieve something like this: namespace A { using ClassB.EnumC = EC; // I would like to have an eqivalent like this public class ClassB { public enum EnumC ...

I have declared enum as below public enum State { KARNATAKA = 1, GUJRAT = 2, ASSAM = 3, MAHARASHTRA = 4, GOA = 5 } From external sources, I get the ...

Does someone know, how can I use an Enum as class constructor parameter? I have created such class: class Coin(Cash, Enum): onePenny = 1 twoPens = 2 fivePens = 5 ones = 0 twos = ...

Simple code as below: fn main() { let R1 = TestResult(10, 20); match R1 { Ok(value) => println!("{}", value), Err(error) => println!("{}", error), } } fn TestResult(...

I use Spring Boot 1.5.11.RELEASE This is my yml file. config: sign: # 1:"by the yml" 2:"from sysConfig" option: 1 This is my Enum class public enum ReadingSignConfigTypeEnum { YML(1, "...

Assuming I have these files, like this: A.h namespace cool { class A { public: enum Status {OK, NotOK, NotOK2}; }; } B.h #include "A.h" namespace cool { class B { public: ...

I'm following a tutorial and I noticed the author(s) declared this enum with what looks like to be multiple types. Based on what I've read online from the Swift Standard Library, I understand enums ...

I have a header file (Fruits.h) in which I have the following snippet of code //Fruits.h class Fruits{ public: enum fruitType {Apple, Mango, Kiwi}; }; I have another header file(FruitBasket.h) ...

I have a situation where I would like to used an instance of an object called Abstraction, which would be a Java interface looking something like: public interface Abstraction { public enum ...

I'm writing a simple parser to read the config file.The config.h interface have only three main functions they are in brief as follows, config_init(); config_dinit(); config_parse(); ...

enum Suit: String { case spades = "♠" case hearts = "♥" case diamonds = "♦" case clubs = "♣" } For example, how can I do something like: for suit in Suit { // do something with ...

Let's say I have an enum: public enum ParameterList { FREQUENCY_ID("500"); ... lot's of different constants here ... private final String param; ParameterList(String param) {...

export enum MyEnum{ Option1, Option2, Option3 } string x = 'Option1'; MyEnum[x] throws an error: Type string is not assignable to type MyEnum however: MyEnum['Option1'] works. I ...

I have this enum with String values, which will be used to tell an API method that logs to a server what kind of serverity a message has. I'm using Swift 1.2, so enums can be mapped to Objective-C @...

Consider the following typescript enum: enum MyEnum { A, B, C }; If I want another type that is the unioned strings of the keys of that enum, I can do the following: type MyEnumKeysAsStrings = ...

For example enum Color {RED, BLUE, YELLOW}; And I want to serialize the type with cereal Color c = RED; JSONOutputArchive archive(std::cout); archive(c); Output looks like "value0" : "RED" or "...

How to convert enum to QString?

6 answers, 18.693 views c++ qt enums
I am trying to use the Qt reflection for converting enum to QString. Here is the part of code: class ModelApple { Q_GADGET Q_ENUMS(AppleType) public: enum AppleType { Big, ...

I am getting my enum value like so: location = Enum.GetName(typeof(Locations), (Locations)record.Friday); And here is my enum: public enum Locations { [Display(Name = "Unspecified")]...

How can I get the name of a Java Enum type given its value? I have the following code which works for a particular Enum type, can I make it more generic? public enum Category { APPLE("3"), ...

What I want to do is something like this: I have enums with combined flagged values. public static class EnumExtension { public static bool IsSet<T>( this T input, T matchTo ) ...

This is my serviceModel.h typedef NS_ENUM(NSInteger, OKServiceType) { OKServiceTypePending = 0, OKServiceTypeAccepted , OKServiceTypeStarted, OKServiceTypeCompleted, ...

I have an enum that looks like this: enum Enum1: String, CustomStringConvertible { case none = "None" case weekly = "Weekly" case monthly = "Monthly" case quarterly = "Quarterly" ...

Related tags

Hot questions

Language

Popular Tags