Scala自我注释类型

时间:2015-05-07 15:25:47

标签: scala

阅读这篇精彩的文章

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)
        }
      }
    }

0 个答案:

没有答案