Scala 中的单个撇号是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/918590/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 01:25:52  来源:igfitidea点击:

What does a single apostrophe mean in Scala?

scalaactor

提问by JeffV

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

ScalaActors.pdf上的这张幻灯片中,单引号表示何时将消息发送给乒乓球演员?

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

回答by Alex Martelli

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

它表示一个符号。例如。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").

Scala 术语'mysym 将通过以下方式调用Symbol 类的构造函数:Symbol("mysym")。