繁体   English   中英

@符号在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 在这种特定情况下,如果您查看文档 ,它实际上是注释的别名。

类型Column = org.squeryl.annotations。 ColumnBase @ scala.annotation.meta.field

ColumnBase使用ClassfileAnnotation扩展Annotation和Annotation

它是一个关系映射:

 @Column(name="sql_column_name")

定义与字段名称不同的表列名称: https : //www.playframework.com/documentation/1.2.3/cheatsheet/model

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM