What does a single apostrophe mean in Scala?

JeffV picture JeffV · May 28, 2009 · Viewed 14.4k times · Source

In this slide show on ScalaActors.pdf what does the single quote indicate when the message is sent to the pong actor?

class Ping(count: int, pong: Pong) extends Actor {
def act() {
   pong ! 'Ping // what does the single quote indicate???
      receive {
         case 'Pong =>
      }
   }
}

Answer

Alex Martelli picture Alex Martelli · May 28, 2009

It indicates a Symbol. Eg. cfr http://www.scala-lang.org/docu/files/api/scala/Symbol.html :

the Scala term 'mysym will invoke the constructor of the Symbol class in the following way: Symbol("mysym").