What does a single apostrophe mean in Scala?

scala actor

12889 观看

2回复

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)


13

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

60

34902 作者的声誉

决定

This defines a literal Symbol. See also this question.

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