我正在通过以下网址阅读教程:http://www.smartjava.org/content/tutorial-getting-started-scala-and-scalatra-part-iii
以下是一段代码:
class BidRepository extends RepositoryBase {
object BidMapping extends Table[(Option[Long], Long, Double, Double, String, Long, Long)]("sc_bid") {
def id = column[Option[Long]]("id", O PrimaryKey)
def forItem = column[Long]("for", O NotNull)
def min = column[Double]("min", O NotNull)
def max = column[Double]("max", O NotNull)
def currency = column[String]("currency")
def bidder = column[Long]("bidder", O NotNull)
def date = column[Long]("date", O NotNull)
def noID = forItem ~ min ~ max ~ currency ~ bidder ~ date
def * = id ~ forItem ~ min ~ max ~ currency ~ bidder ~ date
}
我在这里未能理解的是~
在这里使用的是什么?调用noID
和*
方法时到底发生了什么?这里是否有足够的上下文可以理解,或者~
某些隐含的价值是我在某处找不到的?
答案 0 :(得分:0)
在此示例中,代字号是组合子,表示将两个列结果组合在一起。当连续链接在一起时,就像它是*它意味着将所有这些列的结果一起作为单个结果对象返回。这意味着在名为~
的列类上有一个函数,您正在使用中缀表示法并调用它。实际上它更像是;
columnA.~(columnB)