coder25 coder25 -3 years ago 135
Scala Question

Symbols to represent a string scala

I went through the answer on Purpose of Scala's Symbol?

I want to create a Symbol but it has space in it.


val s = "Hello World"
val syb = 'Hello World

gives compile time error. Is it possible to create a Symbol with spaces?

Answer Source

It is possible to create a Symbol with spaces with the Symbol.apply method:

scala> val syb = Symbol("Hello World")
syb: Symbol = 'Hello World
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download