scala中变量前的@符号是什么意思?
What does the @ sign mean before a variable in scala?
在一些文档中,我在变量前遇到了 @
符号。这个标志是什么意思?
文档中的代码如下:
class Book(val id: Long,
var title: String,
@Column("AUTHOR_ID")
var authorId: Long,
var coAuthorId: Option[Long]) {
def this() = this(0,"",0,Some(0L))
}
这意味着它是一个annotation
. In this specific scenario, it is actually an alias for an annotation if you look at the documentation。
type Column = org.squeryl.annotations.ColumnBase @scala.annotation.meta.field
ColumnBase extends Annotation with Annotation with ClassfileAnnotation
是关系映射:
@Column(name="sql_column_name")
定义了一个不同于字段名称的 table 列名称:
https://www.playframework.com/documentation/1.2.3/cheatsheet/model
在一些文档中,我在变量前遇到了 @
符号。这个标志是什么意思?
文档中的代码如下:
class Book(val id: Long,
var title: String,
@Column("AUTHOR_ID")
var authorId: Long,
var coAuthorId: Option[Long]) {
def this() = this(0,"",0,Some(0L))
}
这意味着它是一个annotation
. In this specific scenario, it is actually an alias for an annotation if you look at the documentation。
type Column = org.squeryl.annotations.ColumnBase @scala.annotation.meta.field
ColumnBase extends Annotation with Annotation with ClassfileAnnotation
是关系映射:
@Column(name="sql_column_name")
定义了一个不同于字段名称的 table 列名称: https://www.playframework.com/documentation/1.2.3/cheatsheet/model