在Scalatra示例代码中找到Scala中的Tilde [英] Tilde in Scala found in Scalatra example code
本文介绍了在Scalatra示例代码中找到Scala中的Tilde的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
刚开始学习此示例代码以了解Scalatra中的命令:
Just ran into this sample code learning about Commands in Scalatra:
protected def handle: Handler = {
case c: CreateTodoCommand =>
add(newTodo(~c.name.value))
}
在这种特殊情况下,~c.name.value
中~
的确切含义是什么?不确定在哪里可以找到有关该特殊符号的更多文档.
In this particular case, what exactly is the relevance of ~
in ~c.name.value
? Not sure where to find more documentation on this particular symbol.
推荐答案
在Scala中:
~x
翻译为
x.unary_~
(这也适用于+
,-
和!
,如这篇文章中所述).因此,您的示例翻译为:
(this also applies to +
,-
and !
as explained in this post). So your example translates to:
add(newTodo(c.name.value.unary_~))
因此可以在value
类型下找到该文档.
The documentation can hence be found at the type of value
.
这篇关于在Scalatra示例代码中找到Scala中的Tilde的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文