What does a single apostrophe mean in Scala?

scala actor

12889 观看


21367 作者的声誉

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 =>
作者: JeffV 的来源 发布者: 2009 年 5 月 28 日

回应 (2)


671083 作者的声誉

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").

作者: Alex Martelli 发布者: 28.05.2009 12:22


34902 作者的声誉


This defines a literal Symbol. See also this question.

作者: Dave Ray 发布者: 28.05.2009 12:23