B { def foo() = println("foo") } ! trait C { def bar() = println("bar") } ! class D extends A with B with C { def f() = foo() // நϝιουΛ࣮ˍτϨΠτBͷfooΛݺͼग़͠ override def bar() = { // τϨΠτCͷbarϝιουΛoverride super.bar() // τϨΠτCͷbarϝιουΛݺͼग़͠ println("BAR") } }
10 ! val q2 = new BasicIntQueue with Doubling q2.put(10) q2.get() // Int = 20 ! val q3 = new BasicIntQueue with Doubling with Filtering q3.put(-10) q3.get() // Int = 20 ʰ4DBMBεέʔϥϒϧϓϩάϥϛϯάʱষΑΓ
MySQLUserRepository class MySQLUserRepository = { def findById(id: Int): User = … } } ! val userService = new UserService with MySQLUserRepositoryComponent ! val user = userService.findById(1)