'How to implement enums with values in Scala 2.12.15

In Java, one can use (from https://www.baeldung.com/java-enum-values#adding-constructor)

public enum Element {
    H("Hydrogen"),
    HE("Helium"),
    NE("Neon");

    public final String label;

    private Element(String label) {
        this.label = label;
    }
}

to construct Enums with string values, such that NE.label would yield "Neon".

How do you do the same thing, but in Scala version 2.12.15? (Please show the above example translated to Scala)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source