package b class Student(){ //this.type是一个返回值 def sayHello(): this.type = { println("sayHello......") //this就是当前对象 this } def run(): this.type ={ println("running......") this } def sleep(): Unit ={ println("sleeping....") } } object lianjie { def main(args: Array[String]): Unit = { var s=new Student() //链式风格的函数 // s.sayHello().run().sleep() } }
09-10
670
09-25
231