Mond Raymond Mond Raymond - 1 year ago 77
Scala Question

How do I create an enum in scala that has an extra field

In Java I have something like this

public enum FlatFileHeaderMapping {


public final int fieldSize;

private FlatFileHeaderMapping(int fieldSize) {
this.fieldSize = fieldSize;


which I can then use it place each line into a map and later access the keys in the map via this enum (like symbols)

Enumeration does not have this quality as far as I can see, and case classes are not ordered like the enum declarations - so cannot be used to match a record layout as shown above. At least not without the support of an ordered collection.

I could be missing something obvious, hence the question!



Answer Source
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download