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

 

相关文章:

  • 2021-12-08
  • 2021-10-16
  • 2022-02-17
  • 2021-05-18
  • 2021-10-08
  • 2021-09-26
  • 2021-09-18
  • 2021-10-06
猜你喜欢
  • 2021-11-26
  • 2021-12-01
  • 2021-07-29
  • 2021-07-16
  • 2021-12-08
  • 2021-06-21
  • 2021-12-02
相关资源
相似解决方案