Scala 学习笔记之函数(3)

mac2022-06-30  62

class student{ def sayHello(name: => String){ println(s"Hello, $name, welcome $name") } } object FunctionDemo3 { def main(args: Array[String]): Unit = { val s = new student() def getSName(s: String): String = {println("call"); s} //传名参数 s.sayHello("Sky") s.sayHello(getSName("Sky")) } } Hello, Sky, welcome Sky call call Hello, Sky, welcome Sky

 

转载于:https://www.cnblogs.com/AK47Sonic/p/7072735.html

相关资源:Scala学习笔记(全)
最新回复(0)