To a large extent, this depends on what you are trying to accomplish.
If you interact with legacy code (especially one that you cannot change) and / or need super-super-high performance ( you usually don’t use it ), the canonical way is to create a type alias forInt . Ie, as in the example of the linked library:
type MyFlags = Int
...
val theseFlags: MyFlags
Int , "" - - "" .
Scala - (ab) BitSet ( ).
"-" , Java enum/EnumSet combo, Enumeration ValueSet. , doc:
scala> object WeekDay extends Enumeration {
| type WeekDay = Value
| val Mon, Tue, Wed, Thu, Fri, Sat, Sun = WeekDay
| }
defined module WeekDay
scala> import WeekDay._
import WeekDay._
scala> var newSet = ValueSet.empty
newSet: WeekDay.ValueSet = WeekDay.ValueSet()
scala> newSet += Mon
scala> newSet
res1: WeekDay.ValueSet = WeekDay.ValueSet(Mon)
scala> newSet & WeekDay.values
res2: WeekDay.ValueSet = WeekDay.ValueSet(Mon)
ValueSet Value - . , Java EnumSet. Scala , Int - type, Value ( ).
.
, . , Int s.
, , - , Enumeration . , , ValueSet BitSet.