Set type parameters?

(tobygroves) #1

Can’t remember if I’ve asked this before but…

Is there a way of using set type parameters? I have an enumeration defined but want to pass a set of those enumerated types to a service function.

The only way I can see is to create an array of the enumerated type but this is very clunky.

(EvgenyK) #2

you can create a method which will transform a set of enumerations to Integer or Int64. enumeration’s values can be stored as bits so Integer can hold 32 values and int64 - 64 values.

(tobygroves) #3

Yeah that could work - ideally I’d like to make such a function generic, so I could use it on any enumerated type, rather than have to duplicate it for each one

(EvgenyK) #4

you can pass enum values as ord values, i.e. [ord(enum1), ord(enum2)].
in method you can use shl.
so, for passing enum1 and enum2, it can be like

(1 shl ord(enum1)) + (1 shl ord(enum2))