我在 Scala Saddle 中找到了以下定义,只是想确保我理解正确。有一个对象定义了一个隐式函数,它将一些 HDF5 I/O 功能暴露给 Frame 类型,以便该writeHdfFile
函数可用于任何 Frame:
object H5Implicits {
/**
* Provides enrichment on Frame object for writing to an HDF5 file.
*/
implicit def frame2H5Writer[RX: ST: ORD, CX: ST: ORD, T: ST](frame: Frame[RX, CX, T]) = new {
/**
* Write a frame in HDF5 format to a file at the path provided
*
* @param path File to write
* @param id Name of the HDF group in which to store frame data
*/
def writeHdfFile(path: String, id: String) {
H5Store.writeFrame(path, id, frame)
}
} // end new
}
但是,我以前从未见过= new {
语法。这是否意味着它每次都在创建并返回一个新函数?为什么这比简单地做更有意义= {