阅读这篇精彩的文章
http://www.cakesolutions.net/teamblogs/2011/12/19/cake-pattern-in-depth
关于自我类型注释,我想知道当我在
中使用self或某个任意名称时会有什么区别this: UserRepositoryComponent =>
或
self: UserRepositoryComponent =>
或
user: UserRepositoryComponent =>
针对:
trait DefaultUserServiceComponent extends UserServiceComponent {
this: UserRepositoryComponent =>
def userService = new DefaultUserService
class DefaultUserService extends UserService {
def findAll = userLocator.findAll
def save(user: User) {
userUpdater.save(user: User)
}
}
}