How can I convert a String to a Symbol in Runtime in Scala?

Viewed 3535

I have a case class that looks like this:

case class Outcome(text: Symbol)

Now I need to change the value of text at runtime. I try to do something like this:

val o2 = o1.copy(text.name = "foo" ++ text.name)

This obviously gives me a compilation error:

type mismatch; found : String required: Symbol

How can I convert a symbol to string, append/prepend something and again change it to a symbol? Or to be more simple, how can I change the name of a symbol?

1 Answers
Related