0

Hello I have the following enumeration and I want to get the values out of the enumeration defined : So here my enumeration object

object ConfType extends Enumeration {
  type ConfType = Value
  val Dfered = Value("Dfered")
  val Dedeo = Value("Dedeo")
 } 

I want to define a new variable which has the value equal to the String "Dfered" I tried this : val confName: ConfType.Value ="Dfered". But I am getting an error. Do you have any idea how to resolce this. Thanks a lot.

scalacode
  • 1,096
  • 1
  • 16
  • 38

2 Answers2

4

If you want the string, try this:

val confName  = ConfType.Dfered.toString
proximator
  • 687
  • 6
  • 18
-1

val confName: ConfType.Value = ConfType.Dfered

mfirry
  • 3,634
  • 1
  • 26
  • 36
  • isn't this a ConfType.Value, or Enumeration.Value type rather than a String? – joel Aug 09 '18 at 10:40
  • Sorry. I figured you wanted that since you explicitly put the type of your val to `: ConfType.Value` – mfirry Aug 09 '18 at 11:34