我是来自Java世界的Scala的新手。 Scala似乎比Java更复杂。此外,我注意到许多Scala构造使用模棱两可的方法名称。除了+,-,*和/很明显之外,是否有任何理由使用这样的方法:
object actorRef {
implicit final class actorRefOps[-T](val ref: actorRef[T]) extends AnyVal {
/**
* Send a message to the actor referenced by this actorRef using *at-most-once*
* messaging semantics.
*/
def !(msg: T): Unit = ref.tell(msg)
}
}
当我看到感叹号发送邮件时,首先想到的是!
另一个例子:
List有一个名为`:::'的方法用于列表连接
使用方法如下:
val oneTwo = List(1,2)
val threeFour = List(3,4)
val oneTwoThreeFour = oneTwo ::: threeFour
println(oneTwo + " and " + threeFour + " were not mutated.")
println("Thus," + oneTwoThreeFour + " is a new list.")
是否有任何技术或体系结构上的原因试图使用特殊字符作为方法名称,或者仅仅是一种“炫耀”?